index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. <template>
  2. <div class="app-container">
  3. <el-form v-show="showSearch" ref="queryForm" :inline="true" :model="queryParams" label-width="68px" size="small">
  4. <el-form-item label="位号" prop="devNo">
  5. <el-input
  6. v-model="queryParams.devNo"
  7. clearable
  8. placeholder="请输入位号"
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="位置" prop="position">
  13. <el-input
  14. v-model="queryParams.position"
  15. clearable
  16. placeholder="请输入位置"
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="月份" prop="month">
  21. <el-date-picker
  22. v-model="month"
  23. :clearable="false"
  24. format="MM"
  25. placeholder="选择月"
  26. popper-class="picker-date"
  27. type="month"
  28. @change="handleQuery">
  29. </el-date-picker>
  30. </el-form-item>
  31. <el-form-item label="年度" prop="year">
  32. <el-date-picker
  33. v-model="year"
  34. :clearable="false"
  35. format="yyyy"
  36. placeholder="请选择年份"
  37. type="year"
  38. @change="handleQuery">
  39. </el-date-picker>
  40. </el-form-item>
  41. <el-form-item label="周期" prop="rate">
  42. <el-radio v-model="queryParams.rate" label="1" @change="handleQuery">上半月</el-radio>
  43. <el-radio v-model="queryParams.rate" label="2" @change="handleQuery">下半月</el-radio>
  44. </el-form-item>
  45. <el-form-item label="计划名称" prop="planId">
  46. <el-select v-model="queryParams.planId" clearable
  47. @change="handleQuery">
  48. <el-option v-for="item in planList"
  49. :key="item.id"
  50. :label="item.planName"
  51. :value="item.id"/>
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item>
  55. <el-button icon="el-icon-search" size="mini" type="primary" @click="handleQuery">搜索</el-button>
  56. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  57. </el-form-item>
  58. </el-form>
  59. <el-row :gutter="10" class="mb8">
  60. <!-- <el-col :span="1.5">
  61. <el-button
  62. v-hasPermi="['fire:annihilator:add']"
  63. icon="el-icon-plus"
  64. plain
  65. size="mini"
  66. type="primary"
  67. @click="handleAdd"
  68. >新增
  69. </el-button>
  70. </el-col>
  71. <el-col :span="1.5">
  72. <el-button
  73. v-hasPermi="['fire:annihilator:edit']"
  74. :disabled="single"
  75. icon="el-icon-edit"
  76. plain
  77. size="mini"
  78. type="success"
  79. @click="handleUpdate"
  80. >修改
  81. </el-button>
  82. </el-col>
  83. <el-col :span="1.5">
  84. <el-button
  85. v-hasPermi="['fire:annihilator:remove']"
  86. :disabled="multiple"
  87. icon="el-icon-delete"
  88. plain
  89. size="mini"
  90. type="danger"
  91. @click="handleDelete"
  92. >删除
  93. </el-button>
  94. </el-col>
  95. <el-col :span="1.5">
  96. <el-button
  97. type="info"
  98. icon="el-icon-upload2"
  99. size="mini"
  100. @click="handleImport"
  101. v-hasPermi="['fire:annihilator:import']"
  102. >导入
  103. </el-button>
  104. </el-col>-->
  105. <el-col :span="1.5">
  106. <el-button
  107. v-hasPermi="['fire:annihilator:export']"
  108. icon="el-icon-download"
  109. plain
  110. size="mini"
  111. type="warning"
  112. @click="handleExport"
  113. >导出
  114. </el-button>
  115. </el-col>
  116. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  117. </el-row>
  118. <el-table v-loading="loading" :data="annihilatorList" :height="clientHeight"
  119. border @selection-change="handleSelectionChange">
  120. <el-table-column align="center" type="selection" width="55"/>
  121. <el-table-column align="center" label="位号" prop="devNo"/>
  122. <el-table-column align="center" label="位置" prop="position"/>
  123. <el-table-column align="center" label="灭火器型号&类型" prop="anniType"/>
  124. <el-table-column align="center" label="数量" prop="anniNum"/>
  125. <el-table-column align="center" label="灭火器材箱外观及箱体内外整洁" prop="anniClean">
  126. <template slot-scope="scope">
  127. <dict-tag :options="dict.type.inspection_status" :value="scope.row.anniClean"/>
  128. </template>
  129. </el-table-column>
  130. <el-table-column align="center" label="灭火器外观/胶管/喷嘴/连接管" prop="anniBody">
  131. <template slot-scope="scope">
  132. <dict-tag :options="dict.type.inspection_status" :value="scope.row.anniBody"/>
  133. </template>
  134. </el-table-column>
  135. <el-table-column align="center" label="灭火器压力" prop="anniPressure">
  136. <template slot-scope="scope">
  137. <dict-tag :options="dict.type.inspection_status" :value="scope.row.anniPressure"/>
  138. </template>
  139. </el-table-column>
  140. <el-table-column align="center" label="灭火器规格及检测时间" prop="anniSpecs">
  141. <template slot-scope="scope">
  142. <dict-tag :options="dict.type.inspection_status" :value="scope.row.anniSpecs"/>
  143. </template>
  144. </el-table-column>
  145. <el-table-column align="center" label="防雨防晒护罩" prop="anniSafe">
  146. <template slot-scope="scope">
  147. <dict-tag :options="dict.type.inspection_status" :value="scope.row.anniSafe"/>
  148. </template>
  149. </el-table-column>
  150. <el-table-column align="center" class-name="small-padding fixed-width" fixed="right" label="操作">
  151. <template slot-scope="scope">
  152. <el-button
  153. icon="el-icon-picture-outline"
  154. size="mini"
  155. type="text"
  156. @click="openFileDialog(scope.row)"
  157. >附件
  158. </el-button>
  159. <!--<el-button
  160. v-hasPermi="['fire:annihilator:edit']"
  161. icon="el-icon-edit"
  162. size="mini"
  163. type="text"
  164. @click="handleUpdate(scope.row)"
  165. >修改
  166. </el-button>
  167. <el-button
  168. v-hasPermi="['fire:annihilator:remove']"
  169. icon="el-icon-delete"
  170. size="mini"
  171. type="text"
  172. @click="handleDelete(scope.row)"
  173. >删除
  174. </el-button>-->
  175. </template>
  176. </el-table-column>
  177. </el-table>
  178. <pagination
  179. v-show="total>0"
  180. :limit.sync="queryParams.pageSize"
  181. :page.sync="queryParams.pageNum"
  182. :total="total"
  183. @pagination="getList"
  184. />
  185. <el-dialog :close-on-click-modal="false" :visible.sync="file.open" append-to-body title="附件详情" width="50%">
  186. <el-tabs v-model="tabName" :stretch="true" type="border-card">
  187. <el-tab-pane label="常规附件" name="a">
  188. <el-empty v-if="file.files.length==0" description="如你所见,这里什么都没有"></el-empty>
  189. <el-image v-for="url in file.files" v-else :key="url" :src="url"></el-image>
  190. </el-tab-pane>
  191. <el-tab-pane label="异常附件" name="b">
  192. <el-empty v-if="file.issuesFiles.length==0" description="如你所见,这里什么都没有"></el-empty>
  193. <el-image v-for="url in file.issuesFiles" v-else :key="url" :src="url"></el-image>
  194. </el-tab-pane>
  195. <el-tab-pane label="异常整改后附件" name="c">
  196. <el-empty v-if="file.repairFile.length==0" description="如你所见,这里什么都没有"></el-empty>
  197. <el-image v-for="url in file.repairFile" v-else :key="url" :src="url"></el-image>
  198. </el-tab-pane>
  199. </el-tabs>
  200. </el-dialog>
  201. <!-- 添加或修改手提式/小推车式灭火器/灭火器材箱对话框 -->
  202. <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" append-to-body width="40%">
  203. <el-form ref="form" :model="form" :rules="rules" label-width="220px">
  204. <el-form-item label="位号" prop="devNo">
  205. <el-input v-model="form.devNo" placeholder="请输入位号"/>
  206. </el-form-item>
  207. <el-form-item label="位置" prop="position">
  208. <el-input v-model="form.position" placeholder="请输入位置"/>
  209. </el-form-item>
  210. <el-form-item label="数量" prop="anniNum">
  211. <el-input v-model="form.anniNum" placeholder="请输入数量"/>
  212. </el-form-item>
  213. <el-form-item label="灭火器材箱外观及箱体内外整洁" prop="anniClean">
  214. <el-input v-model="form.anniClean" placeholder="请输入灭火器材箱外观及箱体内外整洁"/>
  215. </el-form-item>
  216. <el-form-item label="灭火器外观/胶管/喷嘴/连接管" prop="anniBody">
  217. <el-input v-model="form.anniBody" placeholder="请输入灭火器外观/胶管/喷嘴/连接管"/>
  218. </el-form-item>
  219. <el-form-item label="灭火器压力" prop="anniPressure">
  220. <el-input v-model="form.anniPressure" placeholder="请输入灭火器压力"/>
  221. </el-form-item>
  222. <el-form-item label="灭火器规格" prop="anniSpecs">
  223. <el-input v-model="form.anniSpecs" placeholder="请输入灭火器规格"/>
  224. </el-form-item>
  225. <el-form-item label="检测时间" prop="anniCheckDate">
  226. <el-date-picker v-model="form.anniCheckDate"
  227. clearable
  228. placeholder="请选择检测时间"
  229. type="date"
  230. value-format="yyyy-MM-dd">
  231. </el-date-picker>
  232. </el-form-item>
  233. <el-form-item label="防雨防晒护罩" prop="anniSafe">
  234. <el-input v-model="form.anniSafe" placeholder="请输入防雨防晒护罩"/>
  235. </el-form-item>
  236. </el-form>
  237. <div slot="footer" class="dialog-footer">
  238. <el-button type="primary" @click="submitForm">确 定</el-button>
  239. <el-button @click="cancel">取 消</el-button>
  240. </div>
  241. </el-dialog>
  242. <!-- 用户导入对话框 -->
  243. <el-dialog :close-on-click-modal="false" :title="upload.title" :visible.sync="upload.open" append-to-body
  244. width="400px">
  245. <el-upload
  246. ref="upload"
  247. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  248. :auto-upload="false"
  249. :disabled="upload.isUploading"
  250. :headers="upload.headers"
  251. :limit="1"
  252. :on-progress="handleFileUploadProgress"
  253. :on-success="handleFileSuccess"
  254. accept=".xlsx, .xls"
  255. drag
  256. >
  257. <i class="el-icon-upload"></i>
  258. <div class="el-upload__text">
  259. 将文件拖到此处,或
  260. <em>点击上传</em>
  261. </div>
  262. <div slot="tip" class="el-upload__tip">
  263. <!-- <el-checkbox v-model="upload.updateSupport"/>-->
  264. <!-- 是否更新已经存在的用户数据-->
  265. <!-- <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>-->
  266. </div>
  267. <div slot="tip" class="el-upload__tip" style="color:red">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
  268. </el-upload>
  269. <div slot="footer" class="dialog-footer">
  270. <el-button v-loading.fullscreen.lock="fullscreenLoading" type="primary" @click="submitFileForm">确 定
  271. </el-button>
  272. <el-button @click="upload.open = false">取 消</el-button>
  273. </div>
  274. </el-dialog>
  275. <form ref="downloadFileForm" :action="upload.downloadAction" target="FORMSUBMIT">
  276. <input :value="upload.type" hidden name="type"/>
  277. </form>
  278. </div>
  279. </template>
  280. <script>
  281. import {
  282. addAnnihilator,
  283. delAnnihilator,
  284. getAnnihilator,
  285. listAnnihilator,
  286. updateAnnihilator
  287. } from "@/api/patrol/fire/annihilator";
  288. import {getToken} from "@/utils/auth";
  289. import {listAllPlan} from "@/api/patrol/patrol/plan";
  290. export default {
  291. dicts: ['inspection_status'],
  292. name: "Annihilator",
  293. data() {
  294. return {
  295. tabName: 'a',
  296. planList: [],
  297. file: {
  298. open: false,
  299. issuesFiles: [],
  300. repairFile: [],
  301. files: []
  302. },
  303. // 用户导入参数
  304. upload: {
  305. downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
  306. type: "specMain",
  307. // 是否显示弹出层(用户导入)
  308. open: false,
  309. // 弹出层标题(用户导入)
  310. title: "",
  311. // 是否禁用上传
  312. isUploading: false,
  313. // 是否更新已经存在的用户数据
  314. updateSupport: 0,
  315. // 设置上传的请求头部
  316. headers: {Authorization: "Bearer " + getToken()},
  317. // 上传的地址
  318. url: process.env.VUE_APP_BASE_API + "/patrol/annihilator/importData"
  319. },
  320. month: new Date(),
  321. year: new Date(),
  322. // 遮罩层
  323. loading: true,
  324. // 选中数组
  325. ids: [],
  326. // 全屏锁定
  327. fullscreenLoading: false,
  328. // 非单个禁用
  329. single: true,
  330. // 非多个禁用
  331. multiple: true,
  332. // 页面高度
  333. clientHeight: 300,
  334. // 显示搜索条件
  335. showSearch: false,
  336. // 总条数
  337. total: 0,
  338. // 手提式/小推车式灭火器/灭火器材箱表格数据
  339. annihilatorList: [],
  340. // 弹出层标题
  341. title: "",
  342. // 是否显示弹出层
  343. open: false,
  344. // 查询参数
  345. queryParams: {
  346. pageNum: 1,
  347. pageSize: 20,
  348. devNo: null,
  349. position: null,
  350. anniType: null,
  351. anniNum: null,
  352. anniClean: null,
  353. anniBody: null,
  354. anniPressure: null,
  355. anniSpecs: null,
  356. anniCheckDate: null,
  357. anniSafe: null,
  358. month: null,
  359. year: null,
  360. rate: null,
  361. createrCode: null,
  362. createdate: null,
  363. updaterCode: null,
  364. updatedate: null,
  365. remarks: null,
  366. deptId: null
  367. },
  368. // 表单参数
  369. form: {},
  370. // 表单校验
  371. rules: {}
  372. };
  373. },
  374. created() {
  375. if (this.$route.query.year && this.$route.query.month) {
  376. this.year.setFullYear(this.$route.query.year, this.$route.query.month, 1);
  377. this.month.setMonth(this.$route.query.month, 1);
  378. }
  379. if (this.$route.query.planId) {
  380. this.queryParams.planId = parseInt(this.$route.query.planId)
  381. }
  382. if (this.$route.query.id) {
  383. this.queryParams.id = parseInt(this.$route.query.id)
  384. this.queryParams.issuesFlag = '1';
  385. }
  386. //设置表格高度对应屏幕高度
  387. this.$nextTick(() => {
  388. this.clientHeight = document.body.clientHeight - 270
  389. });
  390. if (!this.queryParams.id) {
  391. let query = {
  392. planQuarter: this.month.getMonth() + 1,
  393. planYear: this.year.getFullYear(),
  394. patrolType: '1',
  395. detectionFrequency: this.queryParams.rate
  396. }
  397. listAllPlan(query).then(res => {
  398. this.planList = res.data;
  399. if (res.data.length > 0) {
  400. this.queryParams.planId = res.data[0].id;
  401. }
  402. this.getList();
  403. })
  404. }else{
  405. this.getList();
  406. }
  407. },
  408. methods: {
  409. getPlanList() {
  410. let query = {
  411. planQuarter: this.month.getMonth() + 1,
  412. planYear: this.year.getFullYear(),
  413. patrolType: '1',
  414. detectionFrequency: this.queryParams.rate
  415. }
  416. listAllPlan(query).then(res => {
  417. this.planList = res.data;
  418. })
  419. },
  420. openFileDialog(row) {
  421. this.tabName = 'a'
  422. this.file.issuesFiles = []
  423. this.file.files = []
  424. this.file.repairFile = []
  425. this.file.open = true;
  426. if (row.problemFileUrl) {
  427. this.file.issuesFiles = row.problemFileUrl.split(',').map(item => process.env.VUE_APP_BASE_API + item);
  428. }
  429. if (row.fileUrl) {
  430. this.file.files = row.fileUrl.split(',').map(item => process.env.VUE_APP_BASE_API + item);
  431. }
  432. if (row.repairFile) {
  433. this.file.repairFile = row.repairFile.split(',').map(item => process.env.VUE_APP_BASE_API + item);
  434. }
  435. },
  436. /** 下载模板操作 */
  437. importTemplate() {
  438. this.$refs['downloadFileForm'].submit()
  439. },
  440. // 提交上传文件
  441. submitFileForm() {
  442. this.$refs.upload.submit();
  443. this.fullscreenLoading = true;
  444. },
  445. // 文件上传中处理
  446. handleFileUploadProgress(event, file, fileList) {
  447. this.upload.isUploading = true;
  448. },
  449. // 文件上传成功处理
  450. handleFileSuccess(response, file, fileList) {
  451. this.upload.open = false;
  452. this.upload.isUploading = false;
  453. this.$refs.upload.clearFiles();
  454. this.fullscreenLoading = false;
  455. if (response.data.length > 0) {
  456. let failrow = ''
  457. for (let i = 0; i < response.data.length; i++) {
  458. failrow += response.data[i] + ','
  459. }
  460. this.$alert('导入成功条数:' + response.msg + '<br>' + '失败行数:' + failrow, '导入结果', {dangerouslyUseHTMLString: true});
  461. } else {
  462. this.$alert('导入成功条数:' + response.msg, '导入结果', {dangerouslyUseHTMLString: true});
  463. }
  464. this.getList();
  465. },
  466. /** 导入按钮操作 */
  467. handleImport() {
  468. this.upload.title = "用户导入";
  469. this.upload.open = true;
  470. },
  471. /** 查询手提式/小推车式灭火器/灭火器材箱列表 */
  472. getList() {
  473. this.loading = true;
  474. if (!this.queryParams.id) {
  475. this.queryParams.month = this.month.getMonth() + 1;
  476. this.queryParams.year = this.year.getFullYear();
  477. }
  478. listAnnihilator(this.queryParams).then(response => {
  479. this.annihilatorList = response.rows;
  480. this.total = response.total;
  481. this.loading = false;
  482. });
  483. },
  484. // 取消按钮
  485. cancel() {
  486. this.open = false;
  487. this.reset();
  488. },
  489. // 表单重置
  490. reset() {
  491. this.form = {
  492. id: null,
  493. devNo: null,
  494. position: null,
  495. anniType: null,
  496. anniNum: null,
  497. anniClean: null,
  498. anniBody: null,
  499. anniPressure: null,
  500. anniSpecs: null,
  501. anniCheckDate: null,
  502. anniSafe: null,
  503. month: null,
  504. year: null,
  505. rate: null,
  506. delFlag: null,
  507. createrCode: null,
  508. createdate: null,
  509. updaterCode: null,
  510. updatedate: null,
  511. remarks: null,
  512. deptId: null
  513. };
  514. this.resetForm("form");
  515. },
  516. /** 搜索按钮操作 */
  517. handleQuery() {
  518. this.queryParams.pageNum = 1;
  519. this.getList();
  520. this.getPlanList();
  521. },
  522. /** 重置按钮操作 */
  523. resetQuery() {
  524. this.month = new Date();
  525. this.year = new Date();
  526. this.resetForm("queryForm");
  527. this.handleQuery();
  528. },
  529. // 多选框选中数据
  530. handleSelectionChange(selection) {
  531. this.ids = selection.map(item => item.id)
  532. this.single = selection.length !== 1
  533. this.multiple = !selection.length
  534. },
  535. /** 新增按钮操作 */
  536. handleAdd() {
  537. this.reset();
  538. this.open = true;
  539. this.title = "添加手提式/小推车式灭火器/灭火器材箱";
  540. },
  541. /** 修改按钮操作 */
  542. handleUpdate(row) {
  543. this.reset();
  544. const id = row.id || this.ids
  545. getAnnihilator(id).then(response => {
  546. this.form = response.data;
  547. this.open = true;
  548. this.title = "修改手提式/小推车式灭火器/灭火器材箱";
  549. });
  550. },
  551. /** 提交按钮 */
  552. submitForm() {
  553. this.$refs["form"].validate(valid => {
  554. if (valid) {
  555. if (this.form.id != null) {
  556. updateAnnihilator(this.form).then(response => {
  557. this.msgSuccess("修改成功");
  558. this.open = false;
  559. this.getList();
  560. });
  561. } else {
  562. addAnnihilator(this.form).then(response => {
  563. this.msgSuccess("新增成功");
  564. this.open = false;
  565. this.getList();
  566. });
  567. }
  568. }
  569. });
  570. },
  571. /** 删除按钮操作 */
  572. handleDelete(row) {
  573. const ids = row.id || this.ids;
  574. this.$confirm('是否确认删除手提式/小推车式灭火器/灭火器材箱编号为"' + ids + '"的数据项?').then(function () {
  575. return delAnnihilator(ids);
  576. }).then(() => {
  577. this.getList();
  578. this.msgSuccess("删除成功");
  579. }).catch(() => {
  580. });
  581. },
  582. /** 导出按钮操作 */
  583. handleExport() {
  584. this.download2('fire/annihilator/export', {
  585. ...this.queryParams
  586. }, `annihilator_${new Date().getTime()}.xlsx`)
  587. },
  588. }
  589. };
  590. </script>