index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="20">
  4. <!--机构数据-->
  5. <el-col :span="4" :xs="24">
  6. <org-tree
  7. v-model="queryParams.orgId"
  8. @defaultKey="getDefaultKey"
  9. @checkChange="checkChange"
  10. @click="clickTreeNode"
  11. ></org-tree>
  12. </el-col>
  13. <el-col :span="20" :xs="24">
  14. <!-- 搜索条件 -->
  15. <el-form
  16. :model="queryParams"
  17. ref="search"
  18. size="small"
  19. :inline="true"
  20. v-show="showSearch"
  21. label-width="120px"
  22. >
  23. <el-form-item prop="key" label="关键字">
  24. <el-input
  25. v-model="queryParams.key"
  26. :maxlength="50"
  27. placeholder="请输入搜索关键字"
  28. clearable
  29. />
  30. </el-form-item>
  31. <el-form-item prop="status" label="防区状态">
  32. <el-select
  33. label="防区状态"
  34. v-model="queryParams.status"
  35. placeholder="请选择防区状态"
  36. clearable
  37. >
  38. <el-option
  39. v-for="dict in dict.type.protection_status"
  40. :key="dict.value"
  41. :label="dict.label"
  42. :value="dict.value"
  43. />
  44. </el-select>
  45. </el-form-item>
  46. <el-form-item prop="dateRange" label="布撤防时间范围">
  47. <el-date-picker
  48. v-model="queryParams.dateRange"
  49. type="datetimerange"
  50. format="yyyy-MM-dd HH:mm"
  51. range-separator="至"
  52. start-placeholder="开始日期"
  53. end-placeholder="结束日期"
  54. >
  55. </el-date-picker>
  56. </el-form-item>
  57. <el-form-item>
  58. <el-button
  59. type="primary"
  60. icon="el-icon-search"
  61. size="mini"
  62. @click="getList"
  63. v-hasPermi="['device:protection']"
  64. >搜索</el-button
  65. >
  66. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
  67. >重置</el-button
  68. >
  69. </el-form-item>
  70. </el-form>
  71. <!-- 按纽 -->
  72. <el-row :gutter="10" class="mb8">
  73. <el-col :span="1.5">
  74. <el-button
  75. type="primary"
  76. plain
  77. icon="el-icon-plus"
  78. size="mini"
  79. @click="handleAdd()"
  80. v-hasPermi="['device:protection:add']"
  81. >新增</el-button
  82. >
  83. </el-col>
  84. <!-- <el-col :span="1.5">
  85. <el-button
  86. type="success"
  87. plain
  88. icon="el-icon-edit"
  89. size="mini"
  90. :disabled="single"
  91. @click="handleUpdate"
  92. v-hasPermi="['system:user:edit']"
  93. >修改</el-button
  94. >
  95. </el-col>
  96. <el-col :span="1.5">
  97. <el-button
  98. type="danger"
  99. plain
  100. icon="el-icon-delete"
  101. size="mini"
  102. :disabled="multiple"
  103. @click="handleDelete"
  104. v-hasPermi="['system:user:remove']"
  105. >删除</el-button
  106. >
  107. </el-col>-->
  108. <right-toolbar
  109. :showSearch.sync="showSearch"
  110. @queryTable="getList"
  111. :columns="columns"
  112. ></right-toolbar>
  113. </el-row>
  114. <el-table
  115. v-loading="loading"
  116. :data="pageData"
  117. @selection-change="handleSelectionChange"
  118. >
  119. <el-table-column
  120. type="index"
  121. label="序号"
  122. v-if="columns[0].visible"
  123. ></el-table-column>
  124. <el-table-column
  125. prop="orgName"
  126. label="所属机构"
  127. v-if="columns[1].visible"
  128. ></el-table-column>
  129. <el-table-column
  130. prop="name"
  131. label="防区名称"
  132. v-if="columns[2].visible"
  133. >
  134. </el-table-column>
  135. <el-table-column
  136. prop="allHour"
  137. label="24小时防区"
  138. v-if="columns[3].visible"
  139. ><template slot-scope="r"
  140. >{{ r.row.allHour ? "是" : "否" }}
  141. </template>
  142. </el-table-column>
  143. <el-table-column
  144. prop="status"
  145. label="防区状态"
  146. v-if="columns[4].visible"
  147. >
  148. <template slot-scope="r"
  149. >{{ getLabel(dict.type.protection_status, r.row.status) }}
  150. </template>
  151. </el-table-column>
  152. <el-table-column
  153. prop="statusUpdateTime"
  154. label="布撤防时间"
  155. v-if="columns[5].visible"
  156. >
  157. </el-table-column>
  158. <el-table-column label="操作">
  159. <template slot-scope="r">
  160. <!-- <el-button
  161. size="mini"
  162. type="text"
  163. icon="el-icon-edit"
  164. @click="updateStatus(r.row.id, 1)"
  165. v-hasPermi="['device:protection:maintain']"
  166. >布防</el-button
  167. >
  168. <el-button
  169. size="mini"
  170. type="text"
  171. icon="el-icon-edit"
  172. @click="updateStatus(r.row.id, 0)"
  173. v-hasPermi="['device:protection:maintain']"
  174. >撤防</el-button
  175. > -->
  176. <el-button
  177. size="mini"
  178. type="text"
  179. icon="el-icon-edit"
  180. @click="onEdit(r.row.id)"
  181. v-hasPermi="['device:protection:edit']"
  182. >修改</el-button
  183. >
  184. <el-button
  185. size="mini"
  186. type="text"
  187. icon="el-icon-edit"
  188. @click="onHistory(r.row)"
  189. v-hasPermi="['device:protection']"
  190. >布撤防历史</el-button
  191. >
  192. <el-popconfirm
  193. @confirm="onDel(r.row.id)"
  194. title="点击确定删除防区"
  195. >
  196. <el-button
  197. size="mini"
  198. type="text"
  199. icon="el-icon-delete"
  200. v-hasPermi="['device:protection:remove']"
  201. slot="reference"
  202. >删除</el-button
  203. >
  204. </el-popconfirm>
  205. </template>
  206. </el-table-column>
  207. </el-table>
  208. <pagination
  209. v-show="total > 0"
  210. :total="total"
  211. :page.sync="queryParams.pageNum"
  212. :limit.sync="queryParams.pageSize"
  213. @pagination="getList"
  214. />
  215. </el-col>
  216. </el-row>
  217. <dialog-edit
  218. ref="editDialog"
  219. @success="getList()"
  220. :orgTypeOptions="dict.type.sys_org_type"
  221. :ruleTypeOptions="dict.type.rule_type"
  222. ></dialog-edit>
  223. <dialog-history ref="historyDialog" :statusDict="dict.type.protection_status"></dialog-history>
  224. </div>
  225. </template>
  226. <script>
  227. import OrgTree from "@/components/orgTree";
  228. import { mapState, mapMutations } from "vuex";
  229. import DialogEdit from "./dialog.edit";
  230. import DialogHistory from "./dialog.history";
  231. import * as api from "@/api/resumption/protection";
  232. import { getLabel } from "./../../commonOption";
  233. export default {
  234. name: "protection",
  235. dicts: ["protection_status"],
  236. components: {
  237. DialogEdit,
  238. OrgTree,
  239. DialogHistory,
  240. },
  241. data() {
  242. const { params, query } = this.$route;
  243. return {
  244. isShow: false,
  245. loading: false,
  246. ids: [],
  247. // 非单个禁用
  248. single: true,
  249. // 非多个禁用
  250. multiple: true,
  251. // 显示搜索条件
  252. showSearch: true,
  253. total: 0,
  254. queryParams: {
  255. orgId: null,
  256. checkSub: 0,
  257. key: null,
  258. status: null,
  259. dateRange: null,
  260. pageNum: 1,
  261. pageSize: 10,
  262. ...query,
  263. },
  264. pageData: [],
  265. // 列信息
  266. columns: [
  267. { key: 0, label: `序号`, visible: true },
  268. { key: 1, label: `所属机构`, visible: true },
  269. { key: 2, label: `防区名称`, visible: true },
  270. { key: 3, label: `24小时防区`, visible: true },
  271. { key: 4, label: `防区状态`, visible: true },
  272. { key: 5, label: `布撤防时间`, visible: true },
  273. ],
  274. };
  275. },
  276. props: {},
  277. watch: {},
  278. computed: {
  279. ...mapState([]),
  280. },
  281. methods: {
  282. ...mapMutations([]),
  283. getLabel,
  284. getList() {
  285. this.loading = true;
  286. api
  287. .list(this.queryParams)
  288. .then((response) => {
  289. this.pageData = response.rows;
  290. this.total = response.total;
  291. this.loading = false;
  292. })
  293. .catch(() => {
  294. this.loading = false;
  295. });
  296. },
  297. getDefaultKey(key) {
  298. this.queryParams.orgId = key;
  299. this.getList();
  300. },
  301. handleAdd(id, other = {}) {
  302. this.$refs.editDialog.show(id, other);
  303. },
  304. onEdit(id, other = {}) {
  305. this.$refs.editDialog.show(id, other);
  306. },
  307. onHistory(row) {
  308. this.$refs.historyDialog.show(row);
  309. },
  310. async onDel(id) {
  311. let b=(await api.del(id)).data;
  312. if(b){
  313. this.$message.info("删除成功");
  314. }
  315. this.getList();
  316. },
  317. updateStatus(id, status) {
  318. api.updateStatus(id, status).then((r) => {
  319. this.$message.info("更新状态成功");
  320. this.getList();
  321. });
  322. },
  323. // 多选框选中数据
  324. handleSelectionChange(selection) {
  325. this.ids = selection.map((item) => item.userId);
  326. this.single = selection.length != 1;
  327. this.multiple = !selection.length;
  328. },
  329. /** 重置按钮操作 */
  330. resetQuery() {
  331. this.resetForm("search");
  332. // this.queryParams.orgId = undefined;
  333. // this.$refs.tree.setCurrentKey(null);
  334. this.getList();
  335. },
  336. //单选框状态改变
  337. checkChange(state) {
  338. this.queryParams.checkSub = state;
  339. this.getList();
  340. },
  341. // 节点单击事件
  342. clickTreeNode(data) {
  343. this.queryParams.orgId = data.id;
  344. this.getList();
  345. },
  346. },
  347. mounted() {},
  348. };
  349. </script>
  350. <style lang="scss" scoped>
  351. .brand {
  352. }
  353. </style>