index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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="position">
  5. <el-input
  6. v-model="queryParams.position"
  7. placeholder="请输入位置"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="型号" prop="modelNo">
  14. <el-input
  15. v-model="queryParams.modelNo"
  16. placeholder="请输入型号"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="编号" prop="boxNo">
  23. <el-input
  24. v-model="queryParams.boxNo"
  25. placeholder="请输入编号"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="月度" prop="month">
  32. <el-input
  33. v-model="queryParams.month"
  34. placeholder="请输入月度"
  35. clearable
  36. size="small"
  37. @keyup.enter.native="handleQuery"
  38. />
  39. </el-form-item>
  40. <el-form-item label="年度" prop="year">
  41. <el-input
  42. v-model="queryParams.year"
  43. placeholder="请输入年度"
  44. clearable
  45. size="small"
  46. @keyup.enter.native="handleQuery"
  47. />
  48. </el-form-item>
  49. <el-form-item label="巡检计划" prop="planId">
  50. <el-select
  51. v-model="queryParams.planId"
  52. placeholder="请选择巡检计划"
  53. clearable
  54. size="small"
  55. filterable
  56. @change="handleQuery"
  57. style="width: 200px"
  58. >
  59. <el-option
  60. v-for="item in planOptions"
  61. :key="item.id"
  62. :label="item.planName"
  63. :value="item.id"
  64. />
  65. </el-select>
  66. </el-form-item>
  67. <el-form-item>
  68. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  69. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  70. </el-form-item>
  71. </el-form>
  72. <el-row :gutter="10" class="mb8">
  73. <el-col :span="1.5">
  74. <el-button
  75. type="warning"
  76. icon="el-icon-download"
  77. size="mini"
  78. @click="handleExport"
  79. v-hasPermi="['ps:patrol:list']"
  80. >导出
  81. </el-button>
  82. </el-col>
  83. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  84. </el-row>
  85. <el-table v-loading="loading" :data="cabinetList" @selection-change="handleSelectionChange" :height="clientHeight"
  86. border>
  87. <el-table-column type="selection" width="55" align="center"/>
  88. <el-table-column label="位置" align="center" prop="position" :show-overflow-tooltip="true"/>
  89. <el-table-column label="型号" align="center" prop="modelNo" :show-overflow-tooltip="true"/>
  90. <el-table-column label="编号" align="center" prop="boxNo" :show-overflow-tooltip="true"/>
  91. <el-table-column label="阀门类型" align="center" prop="valveType" :show-overflow-tooltip="true"/>
  92. <el-table-column label="阀门规格" align="center" prop="valveSpecification" :show-overflow-tooltip="true"/>
  93. <el-table-column label="阀门长度" align="center" prop="valveLength" :show-overflow-tooltip="true"/>
  94. <el-table-column label="螺栓点距" align="center" prop="boltPointDistance" :show-overflow-tooltip="true"/>
  95. <el-table-column label="螺栓孔数" align="center" prop="boltHoleCount" :show-overflow-tooltip="true"/>
  96. <el-table-column label="外观" align="center" prop="appearance" :show-overflow-tooltip="true"/>
  97. <el-table-column label="内物品" align="center" prop="internalItems" :show-overflow-tooltip="true"/>
  98. <el-table-column label="阀门" align="center" prop="valve" :show-overflow-tooltip="true"/>
  99. <el-table-column label="通道" align="center" prop="passage" :show-overflow-tooltip="true"/>
  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. exportCabinet,
  145. listCabinet
  146. } from "@/api/ps/inspection/cabinet";
  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: "Cabinet",
  154. components: {Treeselect},
  155. data() {
  156. return {
  157. tabName: 'a',
  158. file: {
  159. open: false,
  160. fileList: [],
  161. queryParams: {
  162. pId: null,
  163. pType: 'ps-cabinet',
  164. pValue: ''
  165. },
  166. },
  167. // 遮罩层
  168. loading: true,
  169. // 选中数组
  170. ids: [],
  171. // 非单个禁用
  172. single: true,
  173. // 非多个禁用
  174. multiple: true,
  175. // 显示搜索条件
  176. showSearch: false,
  177. // 总条数
  178. total: 0,
  179. // 玻璃门消火栓箱和泡沫栓箱检查记录表格数据
  180. cabinetList: [],
  181. // 部门树选项
  182. deptOptions: undefined,
  183. // 巡检计划选项
  184. planOptions: [],
  185. clientHeight: 300,
  186. // 查询参数
  187. queryParams: {
  188. pageNum: 1,
  189. pageSize: 20,
  190. position: null,
  191. modelNo: null,
  192. boxNo: null,
  193. appearance: null,
  194. internalItems: null,
  195. valve: null,
  196. passage: null,
  197. confirmer: null,
  198. checkStatus: null,
  199. checkDate: null,
  200. month: null,
  201. year: null,
  202. createrCode: null,
  203. createdate: null,
  204. updaterCode: null,
  205. updatedate: null,
  206. remarks: null,
  207. deptId: null,
  208. planId: null,
  209. issuesStatus: null,
  210. issuesFlag: null,
  211. valveType: null,
  212. valveSpecification: null,
  213. valveLength: null,
  214. boltPointDistance: null,
  215. boltHoleCount: null
  216. }
  217. };
  218. },
  219. watch: {
  220. // 根据名称筛选部门树
  221. deptName(val) {
  222. this.$refs.tree.filter(val);
  223. }
  224. },
  225. created() {
  226. if (this.$route.query.planId) {
  227. this.queryParams.planId = parseInt(this.$route.query.planId)
  228. }
  229. if (this.$route.query.id) {
  230. this.queryParams.id = parseInt(this.$route.query.id)
  231. this.queryParams.issuesFlag = '1';
  232. }
  233. //设置表格高度对应屏幕高度
  234. this.$nextTick(() => {
  235. this.clientHeight = document.body.clientHeight - 250
  236. })
  237. this.getPlanList();
  238. this.getTreeselect();
  239. },
  240. methods: {
  241. openFileDialog(row) {
  242. this.file.queryParams.pId = row.id;
  243. this.tabName = 'a'
  244. this.file.open = true;
  245. this.getFileList({})
  246. },
  247. getFileList(tab) {
  248. this.file.fileList = [];
  249. let value = 'regular';
  250. if (tab.name == 'a') {
  251. value = 'regular';
  252. } else if (tab.name == 'b') {
  253. value = 'issue';
  254. } else if (tab.name == 'c') {
  255. value = 'repair';
  256. }
  257. this.file.queryParams.pValue = value;
  258. allFileList(this.file.queryParams).then(response => {
  259. this.file.fileList = response;
  260. })
  261. },
  262. getFileUrl(url) {
  263. return process.env.VUE_APP_BASE_API + url;
  264. },
  265. /** 查询玻璃门消火栓箱和泡沫栓箱检查记录列表 */
  266. getList() {
  267. this.loading = true;
  268. listCabinet(this.queryParams).then(response => {
  269. this.cabinetList = response.rows;
  270. this.total = response.total;
  271. this.loading = false;
  272. });
  273. },
  274. /** 查询部门下拉树结构 */
  275. getTreeselect() {
  276. treeselect().then(response => {
  277. this.deptOptions = response.data;
  278. });
  279. },
  280. /** 查询巡检计划列表 */
  281. getPlanList() {
  282. const now = new Date();
  283. const currentYear = now.getFullYear();
  284. const currentMonth = now.getMonth() + 1;
  285. const query = {
  286. planYear: currentYear,
  287. planMonth: currentMonth,
  288. patrolType: '2'
  289. };
  290. listPlan(query).then(response => {
  291. this.planOptions = response.rows || [];
  292. // 如果没有从路由参数传入planId,则默认选择当月最后一个计划
  293. if (!this.$route.query.planId && this.planOptions.length > 0) {
  294. // 按创建时间降序排序,取第一个(最新的)
  295. const sortedPlans = [...this.planOptions].sort((a, b) => {
  296. const dateA = new Date(a.createdate);
  297. const dateB = new Date(b.createdate);
  298. return dateB - dateA;
  299. });
  300. // 选择当月最后一个计划(创建时间最新的)
  301. this.queryParams.planId = sortedPlans[0].id;
  302. }
  303. // 获取计划列表后再查询数据
  304. this.getList();
  305. }).catch(() => {
  306. // 如果获取计划列表失败,仍然查询数据
  307. this.getList();
  308. });
  309. },
  310. /** 搜索按钮操作 */
  311. handleQuery() {
  312. this.queryParams.pageNum = 1;
  313. this.getList();
  314. },
  315. /** 重置按钮操作 */
  316. resetQuery() {
  317. this.resetForm("queryForm");
  318. this.handleQuery();
  319. },
  320. // 多选框选中数据
  321. handleSelectionChange(selection) {
  322. this.ids = selection.map(item => item.id)
  323. this.single = selection.length !== 1
  324. this.multiple = !selection.length
  325. },
  326. /** 导出按钮操作 */
  327. handleExport() {
  328. const queryParams = this.queryParams;
  329. this.$confirm('是否确认导出所有玻璃门消火栓箱和泡沫栓箱检查记录数据项?', "警告", {
  330. confirmButtonText: "确定",
  331. cancelButtonText: "取消",
  332. type: "warning"
  333. }).then(function () {
  334. return exportCabinet(queryParams);
  335. }).then(response => {
  336. this.download(response.msg);
  337. })
  338. },
  339. }
  340. };
  341. </script>