index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  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="$t('名称')" prop="name">
  5. <el-input
  6. v-model="queryParams.name"
  7. :placeholder="$t('请输入') + $t('名称')"
  8. clearable
  9. size="small"
  10. @input="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item :label="$t('检查日期')" prop="inspectdate" label-width="150">
  14. <el-date-picker
  15. v-model="chooseDate"
  16. @change="handleQuery"
  17. type="daterange"
  18. align="right"
  19. unlink-panels
  20. :range-separator="$t('至')"
  21. :start-placeholder="$t('开始日期')"
  22. :end-placeholder="$t('结束日期')"
  23. value-format="yyyy-MM-dd"
  24. :picker-options="pickerOptions">
  25. </el-date-picker>
  26. </el-form-item>
  27. <el-form-item :label="$t('检查状况')" prop="inspectstatus" label-width="150">
  28. <el-select v-model="queryParams.inspectstatus" :placeholder="$t('请选择') + $t('检查状况')" clearable size="small" @change="handleQuery">
  29. <el-option
  30. v-for="dict in inspectstatusOptions"
  31. :key="dict.dictValue"
  32. :label="dict.dictLabel"
  33. :value="dict.dictValue"
  34. />
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item>
  38. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">{{ $t('搜索') }}</el-button>
  39. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('重置') }}</el-button>
  40. </el-form-item>
  41. </el-form>
  42. <el-row :gutter="10" class="mb8">
  43. <el-col :span="1.5">
  44. <el-button
  45. type="primary"
  46. icon="el-icon-plus"
  47. size="mini"
  48. @click="handleAdd"
  49. v-hasPermi="['ehs:firestandpipe:add']"
  50. >{{ $t('新增') }}</el-button>
  51. </el-col>
  52. <el-col :span="1.5">
  53. <el-button
  54. type="success"
  55. icon="el-icon-edit"
  56. size="mini"
  57. :disabled="single"
  58. @click="handleUpdate"
  59. v-hasPermi="['ehs:firestandpipe:edit']"
  60. >{{ $t('修改') }}</el-button>
  61. </el-col>
  62. <el-col :span="1.5">
  63. <el-button
  64. type="danger"
  65. icon="el-icon-delete"
  66. size="mini"
  67. :disabled="multiple"
  68. @click="handleDelete"
  69. v-hasPermi="['ehs:firestandpipe:remove']"
  70. >{{ $t('删除') }}</el-button>
  71. </el-col>
  72. <el-col :span="1.5">
  73. <el-button
  74. type="info"
  75. icon="el-icon-upload2"
  76. size="mini"
  77. @click="handleImport"
  78. v-hasPermi="['ehs:firestandpipe:edit']"
  79. >{{ $t('导入') }}</el-button>
  80. </el-col>
  81. <el-col :span="1.5">
  82. <el-button
  83. type="warning"
  84. icon="el-icon-download"
  85. size="mini"
  86. @click="handleExport"
  87. v-hasPermi="['ehs:firestandpipe:export']"
  88. >{{ $t('导出') }}</el-button>
  89. </el-col>
  90. <el-col :span="1.5">
  91. <el-button
  92. type="primary"
  93. icon="el-icon-download"
  94. size="mini"
  95. :disabled="multiple"
  96. @click="handleBatch"
  97. v-hasPermi="['ehs:firestandpipe:edit']"
  98. >{{ $t('批量') +' '+ $t('修改') }}</el-button>
  99. </el-col>
  100. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  101. </el-row>
  102. <el-table v-loading="loading" :data="firestandpipeList" @selection-change="handleSelectionChange" :cell-class-name="tableCellClassName" :height="clientHeight" border>
  103. <el-table-column type="selection" width="55" align="center" />
  104. <el-table-column :label="$t('检查日期')" align="center" prop="inspectdate" width="200">
  105. <template slot-scope="scope">
  106. <span>{{ parseTime(scope.row.inspectdate, '{y}-{m}-{d}') }}</span>
  107. </template>
  108. </el-table-column>
  109. <el-table-column :label="$t('编号')" align="center" prop="numb" :show-overflow-tooltip="true"/>
  110. <el-table-column :label="$t('名称')" align="center" prop="name" :show-overflow-tooltip="true"/>
  111. <el-table-column :label="$t('位置')" align="center" prop="position" :show-overflow-tooltip="true"/>
  112. <el-table-column :label="$t('检查人')" align="center" prop="inspector" :show-overflow-tooltip="true"/>
  113. <el-table-column :label="$t('检查状况')" align="center" prop="inspectstatus" width="120" :formatter="inspectstatusFormat" />
  114. <el-table-column :label="$t('备注')" align="center" prop="remarks" :show-overflow-tooltip="true"/>
  115. <el-table-column :label="$t('操作')" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
  116. <template slot-scope="scope">
  117. <el-button
  118. size="mini"
  119. type="text"
  120. icon="el-icon-edit"
  121. @click="handleUpdate(scope.row)"
  122. v-hasPermi="['ehs:firestandpipe:edit']"
  123. >{{ $t('修改') }}</el-button>
  124. <el-button
  125. size="mini"
  126. type="text"
  127. icon="el-icon-delete"
  128. @click="handleDelete(scope.row)"
  129. v-hasPermi="['ehs:firestandpipe:remove']"
  130. >{{ $t('删除') }}</el-button>
  131. </template>
  132. </el-table-column>
  133. </el-table>
  134. <pagination
  135. v-show="total>0"
  136. :total="total"
  137. :page.sync="queryParams.pageNum"
  138. :limit.sync="queryParams.pageSize"
  139. @pagination="getList"
  140. />
  141. <!-- 添加或修改消防竖管对话框 -->
  142. <el-dialog :close-on-click-modal="false" v-dialogDrag :title="title" :visible.sync="open" width="500px" append-to-body>
  143. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  144. <el-form-item :label="$t('装置名称')" prop="plantCode">
  145. <el-select v-model="form.plantCode" :placeholder="$t('请选择') + $t('装置名称')">
  146. <el-option
  147. v-for="dict in plantCodeOptions"
  148. :key="dict.dictValue"
  149. :label="dict.dictLabel"
  150. :value="dict.dictValue"
  151. ></el-option>
  152. </el-select>
  153. </el-form-item>
  154. <el-form-item :label="$t('编号')" prop="numb">
  155. <el-input v-model="form.numb" :placeholder="$t('请输入') + $t('编号')" />
  156. </el-form-item>
  157. <el-form-item :label="$t('名称')" prop="name">
  158. <el-input v-model="form.name" :placeholder="$t('请输入') + $t('名称')" />
  159. </el-form-item>
  160. <el-form-item :label="$t('位置')" prop="position">
  161. <el-input v-model="form.position" :placeholder="$t('请输入') + $t('位置')" />
  162. </el-form-item>
  163. <el-form-item :label="$t('检查人')" prop="inspector">
  164. <el-input v-model="form.inspector" :placeholder="$t('请输入') + $t('检查人')" />
  165. </el-form-item>
  166. <el-form-item :label="$t('检查日期')" prop="inspectdate">
  167. <el-date-picker clearable size="small" style="width: 200px"
  168. v-model="form.inspectdate"
  169. type="date"
  170. value-format="yyyy-MM-dd"
  171. :placeholder="$t('请选择') + $t('检查日期')">
  172. </el-date-picker>
  173. </el-form-item>
  174. <el-form-item :label="$t('检查状况')" prop="inspectstatus">
  175. <el-select v-model="form.inspectstatus" :placeholder="$t('请选择') + $t('检查状况')">
  176. <el-option
  177. v-for="dict in inspectstatusOptions"
  178. :key="dict.dictValue"
  179. :label="dict.dictLabel"
  180. :value="dict.dictValue"
  181. ></el-option>
  182. </el-select>
  183. </el-form-item>
  184. <el-form-item :label="$t('备注')" prop="remarks">
  185. <el-input v-model="form.remarks" :placeholder="$t('请输入') + $t('备注')" />
  186. </el-form-item>
  187. <el-form-item :label="$t('归属部门')" prop="deptId">
  188. <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" :placeholder="$t('请选择') + $t('归属部门')" />
  189. </el-form-item>
  190. </el-form>
  191. <div slot="footer" class="dialog-footer">
  192. <el-button type="primary" @click="submitForm">{{ $t('确 定') }}</el-button>
  193. <el-button @click="cancel">{{ $t('取 消') }}</el-button>
  194. </div>
  195. </el-dialog>
  196. <!-- 用户导入对话框 -->
  197. <el-dialog :close-on-click-modal="false" v-dialogDrag :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  198. <el-upload
  199. ref="upload"
  200. :limit="1"
  201. accept=".xlsx, .xls"
  202. :headers="upload.headers"
  203. :action="upload.url"
  204. :disabled="upload.isUploading"
  205. :on-progress="handleFileUploadProgress"
  206. :on-success="handleFileSuccess"
  207. :auto-upload="false"
  208. drag
  209. >
  210. <i class="el-icon-upload"></i>
  211. <div class="el-upload__text">
  212. {{ $t('将文件拖到此处,或') }}
  213. <em>{{ $t('点击上传') }}</em>
  214. </div>
  215. <div class="el-upload__tip" slot="tip">
  216. <!--<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据-->
  217. <el-link type="info" style="font-size:12px" @click="importTemplate">{{ $t('下载模板') }}</el-link>
  218. </div>
  219. <form ref="downloadFileForm" :action="upload.downloadAction" target="FORMSUBMIT">
  220. <input name="type" :value="upload.type" hidden />
  221. </form>
  222. <div class="el-upload__tip" style="color:red" slot="tip">{{ $t('提示:仅允许导入“xls”或“xlsx”格式文件!') }}</div>
  223. </el-upload>
  224. <div slot="footer" class="dialog-footer">
  225. <el-button type="primary" @click="submitFileForm">{{ $t('确 定') }}</el-button>
  226. <el-button @click="upload.open = false">{{ $t('取 消') }}</el-button>
  227. </div>
  228. </el-dialog>
  229. <el-dialog :close-on-click-modal="false" v-dialogDrag :title="$t('批量') + $t('修改')" :visible.sync="batch.open" width="400px" append-to-body>
  230. <el-form ref="form" :model="batchForm" :rules="rules" label-width="80px">
  231. <el-form-item :label="$t('检查状况')" prop="inspectstatus">
  232. <el-select v-model="batchForm.inspectstatus" :placeholder="$t('请选择') + $t('检查状况')">
  233. <el-option
  234. v-for="dict in inspectstatusOptions"
  235. :key="dict.dictValue"
  236. :label="dict.dictLabel"
  237. :value="dict.dictValue"
  238. ></el-option>
  239. </el-select>
  240. </el-form-item>
  241. <el-form-item :label="$t('备注')" prop="remarks">
  242. <el-input type="textarea" v-model="batchForm.remarks" :placeholder="$t('请输入') + $t('备注')" />
  243. </el-form-item>
  244. </el-form>
  245. <div slot="footer" class="dialog-footer">
  246. <el-button type="primary" @click="batchSubmitForm">{{ $t('确 定') }}</el-button>
  247. <el-button @click="cancel">{{ $t('取 消') }}</el-button>
  248. </div>
  249. </el-dialog>
  250. </div>
  251. </template>
  252. <script>
  253. import { listFirestandpipe, batchEdit, getFirestandpipe, delFirestandpipe, addFirestandpipe, updateFirestandpipe, exportFirestandpipe } from "@/api/ehs/firestandpipe";
  254. import { treeselect } from "@/api/system/dept";
  255. import { getToken } from "@/utils/auth";
  256. import Treeselect from "@riophae/vue-treeselect";
  257. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  258. export default {
  259. name: "Firestandpipe",
  260. components: { Treeselect },
  261. data() {
  262. return {
  263. // 遮罩层
  264. loading: true,
  265. // 选中数组
  266. ids: [],
  267. // 非单个禁用
  268. single: true,
  269. // 非多个禁用
  270. multiple: true,
  271. // 显示搜索条件
  272. showSearch: false,
  273. // 总条数
  274. total: 0,
  275. // 消防竖管表格数据
  276. firestandpipeList: [],
  277. // 弹出层标题
  278. title: "",
  279. // 部门树选项
  280. deptOptions: undefined,
  281. clientHeight:300,
  282. // 是否显示弹出层
  283. open: false,
  284. // 装置字典
  285. plantCodeOptions: [],
  286. // 检查状况字典
  287. inspectstatusOptions: [],
  288. // 用户导入参数
  289. upload: {
  290. //下载模板请求地址
  291. downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
  292. //下载模板类型
  293. type: "firestandpipe",
  294. // 是否显示弹出层(用户导入)
  295. open: false,
  296. // 弹出层标题(用户导入)
  297. title: "",
  298. // 是否禁用上传
  299. isUploading: false,
  300. // 是否更新已经存在的用户数据
  301. updateSupport: 0,
  302. // 设置上传的请求头部
  303. headers: { Authorization: "Bearer " + getToken() },
  304. // 上传的地址
  305. url: process.env.VUE_APP_BASE_API + "/ehs/firestandpipe/importData"
  306. },
  307. // 查询参数
  308. queryParams: {
  309. pageNum: 1,
  310. pageSize: 20,
  311. numb: null,
  312. name: null,
  313. position: null,
  314. inspector: null,
  315. inspectdate: null,
  316. startDate: null,
  317. endDate: null,
  318. inspectstatus: null,
  319. remarks: null
  320. },
  321. //日期快速选择
  322. pickerOptions: {
  323. shortcuts: [{
  324. text: this.$t('最近一周'),
  325. onClick(picker) {
  326. const end = new Date();
  327. const start = new Date();
  328. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  329. picker.$emit('pick', [start, end]);
  330. }
  331. }, {
  332. text: this.$t('最近一个月'),
  333. onClick(picker) {
  334. const end = new Date();
  335. const start = new Date();
  336. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  337. picker.$emit('pick', [start, end]);
  338. }
  339. }, {
  340. text: this.$t('最近三个月'),
  341. onClick(picker) {
  342. const end = new Date();
  343. const start = new Date();
  344. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  345. picker.$emit('pick', [start, end]);
  346. }
  347. }]
  348. },
  349. //日期选择器
  350. chooseDate: [],
  351. // 表单参数
  352. form: {},
  353. batch: {
  354. open: false
  355. },
  356. batchForm: {},
  357. // 表单校验
  358. rules: {
  359. plantCode: [
  360. { required: true, message: this.$t('装置') + this.$t('不能为空'), trigger: "change" }
  361. ],
  362. inspector: [
  363. { required: true, message: this.$t('检查人') + this.$t('不能为空'), trigger: "blur" }
  364. ],
  365. inspectdate: [
  366. { required: true, message: this.$t('检查日期') + this.$t('不能为空'), trigger: "blur" }
  367. ],
  368. deptId: [
  369. { required: true, message: this.$t('部门编号') + this.$t('不能为空'), trigger: "blur" }
  370. ],
  371. }
  372. };
  373. },
  374. watch: {
  375. // 根据名称筛选部门树
  376. deptName(val) {
  377. this.$refs.tree.filter(val);
  378. }
  379. },
  380. created() {
  381. //设置表格高度对应屏幕高度
  382. this.$nextTick(() => {
  383. this.clientHeight = (document.body.clientHeight - 80) * 0.8
  384. })
  385. this.getList();
  386. this.getTreeselect();
  387. this.getDicts("PLANT_DIVIDE").then(response => {
  388. this.plantCodeOptions = response.data;
  389. });
  390. this.getDicts("INSPECTSTATUS").then(response => {
  391. this.inspectstatusOptions = response.data;
  392. });
  393. },
  394. methods: {
  395. /** 查询消防竖管列表 */
  396. getList() {
  397. this.loading = true;
  398. listFirestandpipe(this.queryParams).then(response => {
  399. this.firestandpipeList = response.rows;
  400. this.total = response.total;
  401. this.loading = false;
  402. });
  403. },
  404. //根据分数显示颜色提示
  405. tableCellClassName({ row, column, rowIndex, columnIndex }) {
  406. if (columnIndex == 6){
  407. return this.changeColor(row.inspectstatus)
  408. }
  409. },
  410. changeColor (value) {
  411. if(value == 10){
  412. return 'cellNormal'
  413. }else if( value == 12) {
  414. return 'cellMalfunction'
  415. }
  416. },
  417. /** 查询部门下拉树结构 */
  418. getTreeselect() {
  419. treeselect().then(response => {
  420. this.deptOptions = response.data;
  421. });
  422. },
  423. // 装置字典翻译
  424. plantCodeFormat(row, column) {
  425. return this.selectDictLabel(this.plantCodeOptions, row.plantCode);
  426. },
  427. // 检查状况字典翻译
  428. inspectstatusFormat(row, column) {
  429. return this.selectDictLabel(this.inspectstatusOptions, row.inspectstatus);
  430. },
  431. // 取消按钮
  432. cancel() {
  433. this.open = false;
  434. this.reset();
  435. },
  436. // 表单重置
  437. reset() {
  438. this.form = {
  439. id: null,
  440. plantCode: null,
  441. numb: null,
  442. name: null,
  443. area: null,
  444. position: null,
  445. owner: null,
  446. inspector: null,
  447. inspectdate: null,
  448. startDate: null,
  449. endDate: null,
  450. inspectstatus: null,
  451. delFlag: null,
  452. createrCode: null,
  453. createdate: null,
  454. updaterCode: null,
  455. updatedate: null,
  456. deptId: null,
  457. remarks: null
  458. };
  459. this.resetForm("form");
  460. },
  461. /** 搜索按钮操作 */
  462. handleQuery() {
  463. this.queryParams.pageNum = 1;
  464. this.queryParams.startDate = this.chooseDate[0];
  465. this.queryParams.endDate = this.chooseDate[1];
  466. this.getList();
  467. },
  468. /** 重置按钮操作 */
  469. resetQuery() {
  470. this.resetForm("queryForm");
  471. this.chooseDate = "";
  472. this.handleQuery();
  473. },
  474. // 多选框选中数据
  475. handleSelectionChange(selection) {
  476. this.ids = selection.map(item => item.id)
  477. this.single = selection.length!==1
  478. this.multiple = !selection.length
  479. },
  480. /** 新增按钮操作 */
  481. handleAdd() {
  482. this.reset();
  483. this.open = true;
  484. this.title = this.$t('新增') + " " + this.$t('消防竖管');
  485. },
  486. /** 修改按钮操作 */
  487. handleUpdate(row) {
  488. this.reset();
  489. const id = row.id || this.ids
  490. getFirestandpipe(id).then(response => {
  491. this.form = response.data;
  492. this.open = true;
  493. this.title = this.$t('修改') + this.$t('消防竖管');
  494. });
  495. },
  496. /** 提交按钮 */
  497. submitForm() {
  498. this.$refs["form"].validate(valid => {
  499. if (valid) {
  500. if (this.form.id != null) {
  501. updateFirestandpipe(this.form).then(response => {
  502. this.msgSuccess(this.$t('修改成功'));
  503. this.open = false;
  504. this.getList();
  505. });
  506. } else {
  507. addFirestandpipe(this.form).then(response => {
  508. this.msgSuccess(this.$t('新增成功'));
  509. this.open = false;
  510. this.getList();
  511. });
  512. }
  513. /*if (this.form.inspectstatus == 12) {
  514. this.$router.push("/production/accident");
  515. }*/
  516. }
  517. });
  518. },
  519. /** 批量提交按钮 */
  520. batchSubmitForm() {
  521. this.batchForm.ids = this.ids
  522. batchEdit(this.batchForm).then(response => {
  523. this.msgSuccess(this.$t('修改成功'));
  524. this.batch.open = false;
  525. this.getList();
  526. })
  527. },
  528. handleBatch() {
  529. this.batch.open = true
  530. },
  531. /** 删除按钮操作 */
  532. handleDelete(row) {
  533. const ids = row.id || this.ids;
  534. this.$confirm(this.$t('是否确认删除消防竖管编号为"') + ids + '"的数据项?', this.$t('警告'), {
  535. confirmButtonText: this.$t('确定'),
  536. cancelButtonText: this.$t('取消'),
  537. type: "warning"
  538. }).then(function() {
  539. return delFirestandpipe(ids);
  540. }).then(() => {
  541. this.getList();
  542. this.msgSuccess(this.$t('删除成功'));
  543. })
  544. },
  545. /** 导出按钮操作 */
  546. handleExport() {
  547. const queryParams = this.queryParams;
  548. this.$confirm(this.$t('是否确认导出所有消防竖管数据项?'), this.$t('警告'), {
  549. confirmButtonText: this.$t('确定'),
  550. cancelButtonText: this.$t('取消'),
  551. type: "warning"
  552. }).then(function() {
  553. return exportFirestandpipe(queryParams);
  554. }).then(response => {
  555. this.download(response.msg);
  556. })
  557. },
  558. /** 导入按钮操作 */
  559. handleImport() {
  560. this.upload.title = this.$t('用户导入');
  561. this.upload.open = true;
  562. },
  563. /** 下载模板操作 */
  564. importTemplate() {
  565. this.$refs['downloadFileForm'].submit()
  566. },
  567. // 文件上传中处理
  568. handleFileUploadProgress(event, file, fileList) {
  569. this.upload.isUploading = true;
  570. },
  571. // 文件上传成功处理
  572. handleFileSuccess(response, file, fileList) {
  573. this.upload.open = false;
  574. this.upload.isUploading = false;
  575. this.$refs.upload.clearFiles();
  576. if (response.data[0] != null) {
  577. this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据') + "," + this.$t('第') + response.data + this.$t('行数据出现错误导入失败')+"。", this.$t('导入结果'), { dangerouslyUseHTMLString: true });
  578. }else {
  579. this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据'), this.$t('导入结果'), { dangerouslyUseHTMLString: true });
  580. }
  581. this.getList();
  582. },
  583. // 提交上传文件
  584. submitFileForm() {
  585. this.$refs.upload.submit();
  586. }
  587. }
  588. };
  589. </script>