index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="位号" prop="devNo">
  5. <el-input
  6. v-model="queryParams.devNo"
  7. placeholder="请输入位号"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="现场位置" prop="position">
  14. <el-input
  15. v-model="queryParams.position"
  16. placeholder="请输入现场位置"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="年月" prop="yearMonth">
  23. <el-date-picker
  24. v-model="queryParams.yearMonth"
  25. type="month"
  26. placeholder="选择年月"
  27. clearable
  28. size="small"
  29. value-format="yyyy-MM"
  30. style="width: 150px"
  31. @change="handleYearMonthChange"
  32. />
  33. </el-form-item>
  34. <el-form-item label="巡检计划" prop="planId">
  35. <el-select
  36. v-model="queryParams.planId"
  37. placeholder="请选择巡检计划"
  38. clearable
  39. size="small"
  40. filterable
  41. @change="handleQuery"
  42. style="width: 200px"
  43. >
  44. <el-option
  45. v-for="item in planOptions"
  46. :key="item.id"
  47. :label="item.planName"
  48. :value="item.id"
  49. />
  50. </el-select>
  51. </el-form-item>
  52. <el-form-item>
  53. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  54. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  55. </el-form-item>
  56. </el-form>
  57. <el-row :gutter="10" class="mb8">
  58. <el-col :span="1.5">
  59. <el-button
  60. type="warning"
  61. icon="el-icon-download"
  62. size="mini"
  63. @click="handleExport"
  64. v-hasPermi="['ps:patrol:list']"
  65. >导出
  66. </el-button>
  67. </el-col>
  68. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  69. </el-row>
  70. <el-table v-loading="loading" :data="monitorList" @selection-change="handleSelectionChange" :height="clientHeight"
  71. border>
  72. <el-table-column type="selection" width="55" align="center"/>
  73. <el-table-column label="位号" align="center" prop="devNo" :show-overflow-tooltip="true"/>
  74. <el-table-column label="现场位置" align="center" prop="position" :show-overflow-tooltip="true"/>
  75. <el-table-column label="炮头转动" align="center" prop="cannonRotate" :show-overflow-tooltip="true">
  76. <template slot-scope="scope">
  77. <dict-tag :options="dict.type.inspection_status" :value="scope.row.cannonRotate"/>
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="阀门开关" align="center" prop="valveSwitch" :show-overflow-tooltip="true">
  81. <template slot-scope="scope">
  82. <dict-tag :options="dict.type.inspection_status" :value="scope.row.valveSwitch"/>
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="直流喷射" align="center" prop="directJet" :show-overflow-tooltip="true">
  86. <template slot-scope="scope">
  87. <dict-tag :options="dict.type.inspection_status" :value="scope.row.directJet"/>
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="旋转喷雾" align="center" prop="rotateSpray" :show-overflow-tooltip="true">
  91. <template slot-scope="scope">
  92. <dict-tag :options="dict.type.inspection_status" :value="scope.row.rotateSpray"/>
  93. </template>
  94. </el-table-column>
  95. <el-table-column label="消防水出水压力" align="center" prop="waterPressure" :show-overflow-tooltip="true">
  96. <template slot-scope="scope">
  97. <dict-tag :options="dict.type.inspection_status" :value="scope.row.waterPressure"/>
  98. </template>
  99. </el-table-column>
  100. <el-table-column label="确认人" align="center" prop="confirmer" :show-overflow-tooltip="true"/>
  101. <el-table-column label="备注" align="center" prop="remarks" :show-overflow-tooltip="true"/>
  102. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="80">
  103. <template slot-scope="scope">
  104. <el-button
  105. icon="el-icon-picture-outline"
  106. size="mini"
  107. type="text"
  108. @click="openFileDialog(scope.row)"
  109. >附件
  110. </el-button>
  111. </template>
  112. </el-table-column>
  113. </el-table>
  114. <pagination
  115. v-show="total>0"
  116. :total="total"
  117. :page.sync="queryParams.pageNum"
  118. :limit.sync="queryParams.pageSize"
  119. @pagination="getList"
  120. />
  121. <el-dialog :close-on-click-modal="false" :visible.sync="file.open" append-to-body title="附件详情" width="50%">
  122. <el-tabs v-model="tabName" :stretch="true" type="border-card" @tab-click="getFileList">
  123. <el-tab-pane label="常规附件" name="a">
  124. <el-empty v-if="file.fileList.length==0" description="如你所见,这里什么都没有"></el-empty>
  125. <el-image v-for="item in file.fileList" v-else :key="item.fileUrl"
  126. :src="getFileUrl(item.fileUrl)"></el-image>
  127. </el-tab-pane>
  128. <el-tab-pane label="异常附件" name="b">
  129. <el-empty v-if="file.fileList.length==0" description="如你所见,这里什么都没有"></el-empty>
  130. <el-image v-for="item in file.fileList" v-else :key="item.fileUrl"
  131. :src="getFileUrl(item.fileUrl)"></el-image>
  132. </el-tab-pane>
  133. <el-tab-pane label="异常整改后附件" name="c">
  134. <el-empty v-if="file.fileList.length==0" description="如你所见,这里什么都没有"></el-empty>
  135. <el-image v-for="item in file.fileList" v-else :key="item.fileUrl"
  136. :src="getFileUrl(item.fileUrl)"></el-image>
  137. </el-tab-pane>
  138. </el-tabs>
  139. </el-dialog>
  140. </div>
  141. </template>
  142. <script>
  143. import {
  144. exportMonitor,
  145. listMonitor
  146. } from "@/api/ps/inspection/monitor";
  147. import {treeselect} from "@/api/system/dept";
  148. import Treeselect from "@riophae/vue-treeselect";
  149. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  150. import {allFileList} from "@/api/common/commonfile";
  151. import {listPlan} from "@/api/ps/patrol/plan";
  152. export default {
  153. name: "Monitor",
  154. dicts: ['inspection_status'],
  155. components: {Treeselect},
  156. data() {
  157. return {
  158. tabName: 'a',
  159. file: {
  160. open: false,
  161. fileList: [],
  162. queryParams: {
  163. pId: null,
  164. pType: 'ps-monitor',
  165. pValue: ''
  166. },
  167. },
  168. // 遮罩层
  169. loading: true,
  170. // 选中数组
  171. ids: [],
  172. // 非单个禁用
  173. single: true,
  174. // 非多个禁用
  175. multiple: true,
  176. // 显示搜索条件
  177. showSearch: false,
  178. // 总条数
  179. total: 0,
  180. // 现场消防炮检查记录表格数据
  181. monitorList: [],
  182. // 部门树选项
  183. deptOptions: undefined,
  184. // 巡检计划选项
  185. planOptions: [],
  186. clientHeight: 300,
  187. // 查询参数
  188. queryParams: {
  189. pageNum: 1,
  190. pageSize: 20,
  191. devNo: null,
  192. position: null,
  193. cannonRotate: null,
  194. valveSwitch: null,
  195. directJet: null,
  196. rotateSpray: null,
  197. waterPressure: null,
  198. confirmer: null,
  199. checkStatus: null,
  200. checkDate: null,
  201. month: String(new Date().getMonth() + 1).padStart(2, '0'),
  202. year: String(new Date().getFullYear()),
  203. yearMonth: new Date().getFullYear() + '-' + String(new Date().getMonth() + 1).padStart(2, '0'),
  204. createrCode: null,
  205. createdate: null,
  206. updaterCode: null,
  207. updatedate: null,
  208. remarks: null,
  209. deptId: null,
  210. planId: null,
  211. issuesStatus: null,
  212. issuesFlag: null
  213. }
  214. };
  215. },
  216. watch: {
  217. // 根据名称筛选部门树
  218. deptName(val) {
  219. this.$refs.tree.filter(val);
  220. }
  221. },
  222. created() {
  223. if (this.$route.query.planId) {
  224. this.queryParams.planId = parseInt(this.$route.query.planId)
  225. }
  226. if (this.$route.query.id) {
  227. this.queryParams.id = parseInt(this.$route.query.id)
  228. this.queryParams.issuesFlag = '1';
  229. }
  230. //设置表格高度对应屏幕高度
  231. this.$nextTick(() => {
  232. this.clientHeight = document.body.clientHeight - 250
  233. })
  234. this.getPlanList();
  235. this.getTreeselect();
  236. },
  237. methods: {
  238. openFileDialog(row) {
  239. this.file.queryParams.pId = row.id;
  240. this.tabName = 'a'
  241. this.file.open = true;
  242. this.getFileList({})
  243. },
  244. getFileList(tab) {
  245. this.file.fileList = [];
  246. let value = 'regular';
  247. if (tab.name == 'a') {
  248. value = 'regular';
  249. } else if (tab.name == 'b') {
  250. value = 'issue';
  251. } else if (tab.name == 'c') {
  252. value = 'repair';
  253. }
  254. this.file.queryParams.pValue = value;
  255. allFileList(this.file.queryParams).then(response => {
  256. this.file.fileList = response;
  257. })
  258. },
  259. getFileUrl(url) {
  260. return process.env.VUE_APP_BASE_API + url;
  261. },
  262. /** 查询现场消防炮检查记录列表 */
  263. getList() {
  264. this.loading = true;
  265. listMonitor(this.queryParams).then(response => {
  266. this.monitorList = response.rows;
  267. this.total = response.total;
  268. this.loading = false;
  269. });
  270. },
  271. /** 查询部门下拉树结构 */
  272. getTreeselect() {
  273. treeselect().then(response => {
  274. this.deptOptions = response.data;
  275. });
  276. },
  277. /** 查询巡检计划列表 */
  278. getPlanList() {
  279. const now = new Date();
  280. const currentYear = now.getFullYear();
  281. const currentMonth = now.getMonth() + 1;
  282. const query = {
  283. planYear: currentYear,
  284. planMonth: currentMonth,
  285. patrolType: '12'
  286. };
  287. listPlan(query).then(response => {
  288. this.planOptions = response.rows || [];
  289. // 如果没有从路由参数传入planId,则默认选择当月最后一个计划
  290. if (!this.$route.query.planId && this.planOptions.length > 0) {
  291. // 按创建时间降序排序,取第一个(最新的)
  292. const sortedPlans = [...this.planOptions].sort((a, b) => {
  293. const dateA = new Date(a.createdate);
  294. const dateB = new Date(b.createdate);
  295. return dateB - dateA;
  296. });
  297. // 选择当月最后一个计划(创建时间最新的)
  298. this.queryParams.planId = sortedPlans[0].id;
  299. }
  300. // 获取计划列表后再查询数据
  301. this.getList();
  302. }).catch(() => {
  303. // 如果获取计划列表失败,仍然查询数据
  304. this.getList();
  305. });
  306. },
  307. /** 搜索按钮操作 */
  308. handleQuery() {
  309. this.queryParams.pageNum = 1;
  310. this.getList();
  311. },
  312. /** 重置按钮操作 */
  313. resetQuery() {
  314. this.resetForm("queryForm");
  315. this.handleYearMonthChange(this.queryParams.yearMonth);
  316. this.handleQuery();
  317. },
  318. // 多选框选中数据
  319. handleSelectionChange(selection) {
  320. this.ids = selection.map(item => item.id)
  321. this.single = selection.length !== 1
  322. this.multiple = !selection.length
  323. },
  324. /** 导出按钮操作 */
  325. handleExport() {
  326. const queryParams = this.queryParams;
  327. this.$confirm('是否确认导出所有现场消防炮检查记录数据项?', "警告", {
  328. confirmButtonText: "确定",
  329. cancelButtonText: "取消",
  330. type: "warning"
  331. }).then(function () {
  332. return exportMonitor(queryParams);
  333. }).then(response => {
  334. this.download(response.msg);
  335. })
  336. },
  337. /** 年月选择器变化事件 */
  338. handleYearMonthChange(val) {
  339. if (val) {
  340. this.queryParams.year = val.substring(0, 4);
  341. this.queryParams.month = val.substring(5, 7);
  342. } else {
  343. this.queryParams.year = null;
  344. this.queryParams.month = null;
  345. }
  346. }
  347. }
  348. };
  349. </script>