index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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 align="center" label="操作">
  177. <template slot-scope="r">
  178. <!-- <el-button
  179. size="mini"
  180. type="text"
  181. icon="el-icon-edit-outline"
  182. @click="updateStatus(r.row.id, 1)"
  183. v-hasPermi="['device:protectionstatus:maintain']"
  184. >布防</el-button
  185. >
  186. <el-button
  187. size="mini"
  188. type="text"
  189. icon="el-icon-edit-outline"
  190. @click="updateStatus(r.row.id, 0)"
  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="onEdit(r.row.id)"
  199. v-hasPermi="['device:protection:edit']"
  200. >编辑</el-button
  201. > -->
  202. <el-button
  203. size="mini"
  204. type="text"
  205. icon="el-icon-document-copy"
  206. @click="onHistory(r.row)"
  207. v-hasPermi="['device:protection']"
  208. >布撤防历史</el-button
  209. >
  210. <!-- <el-popconfirm
  211. @confirm="onDel(r.row.id)"
  212. title="点击确定删除报警控制器"
  213. >
  214. <el-button
  215. size="mini"
  216. type="text"
  217. icon="el-icon-delete"
  218. v-hasPermi="['device:protection:remove']"
  219. slot="reference"
  220. >删除</el-button
  221. >
  222. </el-popconfirm> -->
  223. </template>
  224. </el-table-column>
  225. </el-table>
  226. <pagination
  227. v-show="total > 0"
  228. :total="total"
  229. :page.sync="queryParams.pageNum"
  230. :limit.sync="queryParams.pageSize"
  231. @pagination="getList"
  232. />
  233. </div>
  234. </el-col>
  235. </el-row>
  236. <dialog-edit
  237. ref="editDialog"
  238. @success="getList()"
  239. :orgTypeOptions="dict.type.sys_org_type"
  240. :ruleTypeOptions="dict.type.rule_type"
  241. ></dialog-edit>
  242. <dialog-history
  243. ref="historyDialog"
  244. :statusDict="dict.type.protection_status"
  245. ></dialog-history>
  246. </div>
  247. </template>
  248. <script>
  249. // import OrgTree from "@/components/orgTree";
  250. import OrgTree from "@/components/orgTree/orgQuerySelector.vue";
  251. import DialogEdit from "./dialog.edit";
  252. import DialogHistory from "./dialog.history";
  253. import * as api from "@/api/resumption/protection";
  254. import { getLabel } from "./../../commonOption";
  255. import { mapGetters } from "vuex";
  256. import dayjs from "dayjs";
  257. import DataRangePicker from "@/components/dateTime/daterange.picker.vue";
  258. export default {
  259. name: "protection",
  260. dicts: ["protection_status"],
  261. components: {
  262. DialogEdit,
  263. OrgTree,
  264. DialogHistory,
  265. DataRangePicker,
  266. },
  267. data() {
  268. const { params, query } = this.$route;
  269. return {
  270. isShow: false,
  271. loading: false,
  272. ids: [],
  273. // 非单个禁用
  274. single: true,
  275. // 非多个禁用
  276. multiple: true,
  277. // 显示搜索条件
  278. showSearch: true,
  279. total: 0,
  280. selectedOrgName: null,
  281. queryParams: {
  282. orgId: null,
  283. checkSub: true,
  284. key: null,
  285. status: null,
  286. dateRange: null,
  287. pageNum: 1,
  288. pageSize: 10,
  289. ...query,
  290. },
  291. pageData: [],
  292. // 列信息
  293. columns: [
  294. { key: 0, label: `序号`, visible: true },
  295. { key: 1, label: `所属机构`, visible: true },
  296. { key: 2, label: `报警控制器名称`, visible: true },
  297. { key: 3, label: `报警控制器状态`, visible: true },
  298. { key: 4, label: `登记人`, visible: true },
  299. { key: 5, label: `最近登记时间`, visible: true },
  300. ],
  301. };
  302. },
  303. props: {},
  304. watch: {},
  305. computed: {
  306. ...mapGetters(["orgId", "orgName"]),
  307. },
  308. methods: {
  309. getLabel,
  310. getList() {
  311. this.loading = true;
  312. this.pageData = [];
  313. api
  314. .list(this.queryParams)
  315. .then((response) => {
  316. this.pageData = response.rows;
  317. this.total = response.total;
  318. this.loading = false;
  319. })
  320. .catch(() => {
  321. this.loading = false;
  322. });
  323. },
  324. handleAdd(id, other = {}) {
  325. this.$refs.editDialog.show(id, other);
  326. },
  327. handleExport() {
  328. if (this.total == 0) {
  329. this.$message.error({
  330. message: `无可用数据导出!`,
  331. type: "error",
  332. duration: 2000,
  333. });
  334. return;
  335. }
  336. this.download(
  337. "/core/resumption/protection/export",
  338. {
  339. ...this.queryParams,
  340. },
  341. `${this.selectedOrgName}-布撤防情况跟踪-${dayjs(new Date()).format(
  342. "YYYYMMDD"
  343. )}.xlsx`
  344. );
  345. },
  346. onEdit(id, other = {}) {
  347. this.$refs.editDialog.show(id, other);
  348. },
  349. onHistory(row) {
  350. this.$refs.historyDialog.show(row);
  351. },
  352. async onDel(id) {
  353. let b = (await api.del(id)).data;
  354. if (b) {
  355. this.$message.info("删除成功");
  356. }
  357. this.getList();
  358. },
  359. updateStatus(id, status) {
  360. api.updateStatus(id, status).then((r) => {
  361. this.$message.info("更新状态成功");
  362. this.getList();
  363. });
  364. },
  365. // 多选框选中数据
  366. handleSelectionChange(selection) {
  367. this.ids = selection.map((item) => item.userId);
  368. this.single = selection.length != 1;
  369. this.multiple = !selection.length;
  370. },
  371. /** 重置按钮操作 */
  372. resetQuery() {
  373. this.resetForm("search");
  374. this.queryParams.dateRange = null;
  375. this.queryParams.orgId = this.orgId;
  376. this.selectedOrgName = this.orgName;
  377. this.queryParams.checkSub = true;
  378. this.$refs["orgTree"].setCheckSub(this.queryParams.checkSub);
  379. // this.queryParams.orgId = undefined;
  380. // this.$refs.tree.setCurrentKey(null);
  381. this.getList();
  382. },
  383. //单选框状态改变
  384. checkChange(state) {
  385. this.queryParams.checkSub = state;
  386. this.getList();
  387. },
  388. getDefaultOrg(node) {
  389. this.queryParams.orgId = node.id;
  390. this.selectedOrgName = node.shortName;
  391. this.getList();
  392. },
  393. // 节点单击事件
  394. clickTreeNode(data) {
  395. this.queryParams.orgId = data.id;
  396. this.selectedOrgName = data.shortName;
  397. this.getList();
  398. },
  399. },
  400. mounted() {},
  401. };
  402. </script>
  403. <style lang="scss" scoped>
  404. /* .search_key{
  405. ::v-deep .el-form-item__label{
  406. width:60px !important;
  407. }
  408. } */
  409. </style>