index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  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="waterName"label-width="150">
  5. <el-input
  6. v-model="queryParams.waterName"
  7. :placeholder="$t('请输入') + $t('污水名称')"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item>
  14. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">{{ $t('搜索') }}</el-button>
  15. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('重置') }}</el-button>
  16. </el-form-item>
  17. </el-form>
  18. <el-row :gutter="10" class="mb8">
  19. <el-col :span="1.5">
  20. <el-button
  21. type="primary"
  22. icon="el-icon-plus"
  23. size="mini"
  24. @click="handleAdd"
  25. v-hasPermi="['ehs:water:add']"
  26. >{{ $t('新增') }}</el-button>
  27. </el-col>
  28. <el-col :span="1.5">
  29. <el-button
  30. type="success"
  31. icon="el-icon-edit"
  32. size="mini"
  33. :disabled="single"
  34. @click="handleUpdate"
  35. v-hasPermi="['ehs:water:edit']"
  36. >{{ $t('修改') }}</el-button>
  37. </el-col>
  38. <el-col :span="1.5">
  39. <el-button
  40. type="danger"
  41. icon="el-icon-delete"
  42. size="mini"
  43. :disabled="multiple"
  44. @click="handleDelete"
  45. v-hasPermi="['ehs:water:remove']"
  46. >{{ $t('删除') }}</el-button>
  47. </el-col>
  48. <el-col :span="1.5">
  49. <el-button
  50. type="info"
  51. icon="el-icon-upload2"
  52. size="mini"
  53. @click="handleImport"
  54. v-hasPermi="['ehs:water:edit']"
  55. >{{ $t('导入') }}</el-button>
  56. </el-col>
  57. <el-col :span="1.5">
  58. <el-button
  59. type="warning"
  60. icon="el-icon-download"
  61. size="mini"
  62. @click="handleExport"
  63. v-hasPermi="['ehs:water:export']"
  64. >{{ $t('导出') }}</el-button>
  65. </el-col>
  66. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  67. </el-row>
  68. <el-table v-loading="loading" :data="waterList" @selection-change="handleSelectionChange" :height="clientHeight" border>
  69. <el-table-column type="selection" width="55" align="center" />
  70. <el-table-column :label="$t('污水名称')" align="center" prop="waterName" :show-overflow-tooltip="true"/>
  71. <el-table-column :label="$t('流量')" align="center" prop="flow" :show-overflow-tooltip="true"/>
  72. <el-table-column :label="$t('水源')" align="center" prop="origin" :show-overflow-tooltip="true"/>
  73. <el-table-column :label="$t('污水处理厂')" align="center" prop="wwtp" :show-overflow-tooltip="true" width="100"/>
  74. <el-table-column :label="$t('排放至')" align="center" prop="dischargeTo" :show-overflow-tooltip="true"/>
  75. <el-table-column :label="$t('严重')" align="center" prop="severity" :show-overflow-tooltip="true"/>
  76. <el-table-column :label="$t('可能性')" align="center" prop="probability" :show-overflow-tooltip="true"/>
  77. <el-table-column :label="$t('风险')" align="center" prop="risk" :show-overflow-tooltip="true"/>
  78. <el-table-column :label="$t('现有防护措施')" align="center" prop="existsMeasures" :show-overflow-tooltip="true" width="200"/>
  79. <el-table-column :label="$t('残余风险')" align="center" prop="residualRisk" :show-overflow-tooltip="true" />
  80. <el-table-column :label="$t('进一步措施')" align="center" prop="furtherMeasures" :show-overflow-tooltip="true" width="200"/>
  81. <el-table-column :label="$t('负责人')" align="center" prop="owner" :show-overflow-tooltip="true"/>
  82. <el-table-column :label="$t('截止日期')" align="center" prop="deadline" width="100">
  83. <template slot-scope="scope">
  84. <span>{{ parseTime(scope.row.deadline, '{y}-{m}-{d}') }}</span>
  85. </template>
  86. </el-table-column>
  87. <el-table-column :label="$t('操作')" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
  88. <template slot-scope="scope">
  89. <el-button
  90. size="mini"
  91. type="text"
  92. icon="el-icon-edit"
  93. @click="handleUpdate(scope.row)"
  94. v-hasPermi="['ehs:water:edit']"
  95. >{{ $t('修改') }}</el-button>
  96. <el-button
  97. size="mini"
  98. type="text"
  99. icon="el-icon-delete"
  100. @click="handleDelete(scope.row)"
  101. v-hasPermi="['ehs:water:remove']"
  102. >{{ $t('删除') }}</el-button>
  103. </template>
  104. </el-table-column>
  105. </el-table>
  106. <pagination
  107. v-show="total>0"
  108. :total="total"
  109. :page.sync="queryParams.pageNum"
  110. :limit.sync="queryParams.pageSize"
  111. @pagination="getList"
  112. />
  113. <!-- 添加或修改废水风险评估对话框 -->
  114. <el-dialog v-dialogDrag :title="title" :visible.sync="open" width="500px" append-to-body>
  115. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  116. <el-form-item :label="$t('装置名称')" prop="plantCode">
  117. <el-select v-model="form.plantCode" :placeholder="$t('请选择') + $t('装置名称')">
  118. <el-option
  119. v-for="dict in plantCodeOptions"
  120. :key="dict.dictValue"
  121. :label="dict.dictLabel"
  122. :value="dict.dictValue"
  123. ></el-option>
  124. </el-select>
  125. </el-form-item>
  126. <el-form-item :label="$t('流量')" prop="flow">
  127. <el-input v-model="form.flow" :placeholder="$t('请输入') + $t('流量')" />
  128. </el-form-item>
  129. <el-form-item :label="$t('污水名称')" prop="waterName">
  130. <el-input v-model="form.waterName" :placeholder="$t('请输入') + $t('污水名称')" />
  131. </el-form-item>
  132. <el-form-item :label="$t('水源')" prop="origin">
  133. <el-input v-model="form.origin" :placeholder="$t('请输入') + $t('水源')" />
  134. </el-form-item>
  135. <el-form-item :label="$t('污水处理厂')" prop="wwtp">
  136. <el-input v-model="form.wwtp" :placeholder="$t('请输入') + $t('污水处理厂')" />
  137. </el-form-item>
  138. <el-form-item :label="$t('排放至')" prop="dischargeTo">
  139. <el-input v-model="form.dischargeTo" :placeholder="$t('请输入') + $t('排放至')" />
  140. </el-form-item>
  141. <el-form-item :label="$t('严重')" prop="severity">
  142. <el-input v-model="form.severity" :placeholder="$t('请输入') + $t('严重')" />
  143. </el-form-item>
  144. <el-form-item :label="$t('可能性')" prop="probability">
  145. <el-input v-model="form.probability" :placeholder="$t('请输入') + $t('可能性')" />
  146. </el-form-item>
  147. <el-form-item :label="$t('风险')" prop="risk">
  148. <el-input v-model="form.risk" :placeholder="$t('请输入') + $t('风险')" />
  149. </el-form-item>
  150. <el-form-item :label="$t('残余风险')" prop="residualRisk">
  151. <el-input v-model="form.residualRisk" :placeholder="$t('请输入') + $t('残余风险')" />
  152. </el-form-item>
  153. <el-form-item :label="$t('现有防护措施')" prop="existsMeasures">
  154. <el-input v-model="form.existsMeasures" type="textarea" :placeholder="$t('请输入') + $t('内容')" />
  155. </el-form-item>
  156. <el-form-item :label="$t('进一步措施')" prop="furtherMeasures">
  157. <el-input v-model="form.furtherMeasures" type="textarea" :placeholder="$t('请输入') + $t('内容')" />
  158. </el-form-item>
  159. <el-form-item :label="$t('负责人')" prop="owner">
  160. <el-input v-model="form.owner" :placeholder="$t('请选择') + $t('负责人')" />
  161. </el-form-item>
  162. <el-form-item :label="$t('截止日期')" prop="deadline">
  163. <el-date-picker clearable size="small" style="width: 200px"
  164. v-model="form.deadline"
  165. type="date"
  166. value-format="yyyy-MM-dd"
  167. :placeholder="$t('请选择') + $t('截止日期')">
  168. </el-date-picker>
  169. </el-form-item>
  170. <el-form-item :label="$t('备注')" prop="remarks">
  171. <el-input v-model="form.remarks" type="textarea" :placeholder="$t('请输入') + $t('备注')" />
  172. </el-form-item>
  173. <el-form-item :label="$t('归属部门')" prop="deptId">
  174. <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" :placeholder="$t('请选择') + $t('归属部门')" />
  175. </el-form-item>
  176. </el-form>
  177. <div slot="footer" class="dialog-footer">
  178. <el-button type="primary" @click="submitForm">{{ $t('确 定') }}</el-button>
  179. <el-button @click="cancel">{{ $t('取 消') }}</el-button>
  180. </div>
  181. </el-dialog>
  182. <!-- 用户导入对话框 -->
  183. <el-dialog v-dialogDrag :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  184. <el-upload
  185. ref="upload"
  186. :limit="1"
  187. accept=".xlsx, .xls"
  188. :headers="upload.headers"
  189. :action="upload.url"
  190. :disabled="upload.isUploading"
  191. :on-progress="handleFileUploadProgress"
  192. :on-success="handleFileSuccess"
  193. :auto-upload="false"
  194. drag
  195. >
  196. <i class="el-icon-upload"></i>
  197. <div class="el-upload__text">
  198. {{ $t('将文件拖到此处,或') }}
  199. <em>{{ $t('点击上传') }}</em>
  200. </div>
  201. <div class="el-upload__tip" slot="tip">
  202. <!--<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据-->
  203. <el-link type="info" style="font-size:12px" @click="importTemplate">{{ $t('下载模板') }}</el-link>
  204. </div>
  205. <form ref="downloadFileForm" :action="upload.downloadAction" target="FORMSUBMIT">
  206. <input name="type" :value="upload.type" hidden />
  207. </form>
  208. <div class="el-upload__tip" style="color:red" slot="tip">{{ $t('提示:仅允许导入“xls”或“xlsx”格式文件!') }}</div>
  209. </el-upload>
  210. <div slot="footer" class="dialog-footer">
  211. <el-button type="primary" @click="submitFileForm">{{ $t('确 定') }}</el-button>
  212. <el-button @click="upload.open = false">{{ $t('取 消') }}</el-button>
  213. </div>
  214. </el-dialog>
  215. </div>
  216. </template>
  217. <script>
  218. import { listWater, getWater, delWater, addWater, updateWater, exportWater } from "@/api/ehs/water";
  219. import { treeselect } from "@/api/system/dept";
  220. import { getToken } from "@/utils/auth";
  221. import Treeselect from "@riophae/vue-treeselect";
  222. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  223. export default {
  224. name: "Water",
  225. components: { Treeselect },
  226. data() {
  227. return {
  228. // 遮罩层
  229. loading: true,
  230. // 选中数组
  231. ids: [],
  232. // 非单个禁用
  233. single: true,
  234. // 非多个禁用
  235. multiple: true,
  236. // 显示搜索条件
  237. showSearch: false,
  238. // 总条数
  239. total: 0,
  240. // 废水风险评估表格数据
  241. waterList: [],
  242. // 弹出层标题
  243. title: "",
  244. // 部门树选项
  245. deptOptions: undefined,
  246. clientHeight:300,
  247. // 是否显示弹出层
  248. open: false,
  249. // 装置字典
  250. plantCodeOptions: [],
  251. // 用户导入参数
  252. upload: {
  253. //下载模板请求地址
  254. downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
  255. //下载模板类型
  256. type: "water",
  257. // 是否显示弹出层(用户导入)
  258. open: false,
  259. // 弹出层标题(用户导入)
  260. title: "",
  261. // 是否禁用上传
  262. isUploading: false,
  263. // 是否更新已经存在的用户数据
  264. updateSupport: 0,
  265. // 设置上传的请求头部
  266. headers: { Authorization: "Bearer " + getToken() },
  267. // 上传的地址
  268. url: process.env.VUE_APP_BASE_API + "/ehs/water/importData"
  269. },
  270. // 查询参数
  271. queryParams: {
  272. pageNum: 1,
  273. pageSize: 20,
  274. plantCode: null,
  275. flow: null,
  276. waterName: null,
  277. origin: null,
  278. wwtp: null,
  279. dischargeTo: null,
  280. severity: null,
  281. probability: null,
  282. risk: null,
  283. residualRisk: null,
  284. existsMeasures: null,
  285. furtherMeasures: null,
  286. owner: null,
  287. deadline: null,
  288. remarks: null
  289. },
  290. // 表单参数
  291. form: {},
  292. // 表单校验
  293. rules: {
  294. plantCode: [
  295. { required: true, message: this.$t('装置') + this.$t('不能为空'), trigger: "change" }
  296. ],
  297. deptId: [
  298. { required: true, message: this.$t('部门编号') + this.$t('不能为空'), trigger: "blur" }
  299. ]
  300. }
  301. };
  302. },
  303. watch: {
  304. // 根据名称筛选部门树
  305. deptName(val) {
  306. this.$refs.tree.filter(val);
  307. }
  308. },
  309. created() {
  310. //设置表格高度对应屏幕高度
  311. this.$nextTick(() => {
  312. this.clientHeight = (document.body.clientHeight - 80) * 0.8
  313. })
  314. this.getList();
  315. this.getTreeselect();
  316. this.getDicts("PLANT_DIVIDE").then(response => {
  317. this.plantCodeOptions = response.data;
  318. });
  319. },
  320. methods: {
  321. /** 查询废水风险评估列表 */
  322. getList() {
  323. this.loading = true;
  324. listWater(this.queryParams).then(response => {
  325. this.waterList = response.rows;
  326. this.total = response.total;
  327. this.loading = false;
  328. });
  329. },
  330. /** 查询部门下拉树结构 */
  331. getTreeselect() {
  332. treeselect().then(response => {
  333. this.deptOptions = response.data;
  334. });
  335. },
  336. // 装置字典翻译
  337. plantCodeFormat(row, column) {
  338. return this.selectDictLabel(this.plantCodeOptions, row.plantCode);
  339. },
  340. // 取消按钮
  341. cancel() {
  342. this.open = false;
  343. this.reset();
  344. },
  345. // 表单重置
  346. reset() {
  347. this.form = {
  348. id: null,
  349. plantCode: null,
  350. flow: null,
  351. waterName: null,
  352. origin: null,
  353. wwtp: null,
  354. dischargeTo: null,
  355. severity: null,
  356. probability: null,
  357. risk: null,
  358. residualRisk: null,
  359. existsMeasures: null,
  360. furtherMeasures: null,
  361. owner: null,
  362. deadline: null,
  363. delFlag: null,
  364. createrCode: null,
  365. createdate: null,
  366. updaterCode: null,
  367. updatedate: null,
  368. deptId: null,
  369. remarks: null
  370. };
  371. this.resetForm("form");
  372. },
  373. /** 搜索按钮操作 */
  374. handleQuery() {
  375. this.queryParams.pageNum = 1;
  376. this.getList();
  377. },
  378. /** 重置按钮操作 */
  379. resetQuery() {
  380. this.resetForm("queryForm");
  381. this.handleQuery();
  382. },
  383. // 多选框选中数据
  384. handleSelectionChange(selection) {
  385. this.ids = selection.map(item => item.id)
  386. this.single = selection.length!==1
  387. this.multiple = !selection.length
  388. },
  389. /** 新增按钮操作 */
  390. handleAdd() {
  391. this.reset();
  392. this.open = true;
  393. this.title = this.$t('新增') + " " + this.$t('废水风险评估');
  394. },
  395. /** 修改按钮操作 */
  396. handleUpdate(row) {
  397. this.reset();
  398. const id = row.id || this.ids
  399. getWater(id).then(response => {
  400. this.form = response.data;
  401. this.open = true;
  402. this.title = this.$t('修改')+ this.$t('废水风险评估');
  403. });
  404. },
  405. /** 提交按钮 */
  406. submitForm() {
  407. this.$refs["form"].validate(valid => {
  408. if (valid) {
  409. if (this.form.id != null) {
  410. updateWater(this.form).then(response => {
  411. this.msgSuccess(this.$t('修改成功'));
  412. this.open = false;
  413. this.getList();
  414. });
  415. } else {
  416. addWater(this.form).then(response => {
  417. this.msgSuccess(this.$t('新增成功'));
  418. this.open = false;
  419. this.getList();
  420. });
  421. }
  422. }
  423. });
  424. },
  425. /** 删除按钮操作 */
  426. handleDelete(row) {
  427. const ids = row.id || this.ids;
  428. this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
  429. confirmButtonText: this.$t('确定'),
  430. cancelButtonText: this.$t('取消'),
  431. type: "warning"
  432. }).then(function() {
  433. return delWater(ids);
  434. }).then(() => {
  435. this.getList();
  436. this.msgSuccess(this.$t('删除成功'));
  437. })
  438. },
  439. /** 导出按钮操作 */
  440. handleExport() {
  441. const queryParams = this.queryParams;
  442. this.$confirm(this.$t('是否确认导出所有废水风险评估数据项?'), this.$t('警告'), {
  443. confirmButtonText: this.$t('确定'),
  444. cancelButtonText: this.$t('取消'),
  445. type: "warning"
  446. }).then(function() {
  447. return exportWater(queryParams);
  448. }).then(response => {ss
  449. this.download(response.msg);
  450. })
  451. },
  452. /** 导入按钮操作 */
  453. handleImport() {
  454. this.upload.title = this.$t('用户导入');
  455. this.upload.open = true;
  456. },
  457. /** 下载模板操作 */
  458. importTemplate() {
  459. this.$refs['downloadFileForm'].submit()
  460. },
  461. // 文件上传中处理
  462. handleFileUploadProgress(event, file, fileList) {
  463. this.upload.isUploading = true;
  464. },
  465. // 文件上传成功处理
  466. handleFileSuccess(response, file, fileList) {
  467. this.upload.open = false;
  468. this.upload.isUploading = false;
  469. this.$refs.upload.clearFiles();
  470. if (response.data[0] != null) {
  471. this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据') + "," + this.$t('第') + response.data + this.$t('行数据出现错误导入失败')+"。", this.$t('导入结果'), { dangerouslyUseHTMLString: true });
  472. }else {
  473. this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据'), this.$t('导入结果'), { dangerouslyUseHTMLString: true });
  474. }
  475. this.getList();
  476. },
  477. // 提交上传文件
  478. submitFileForm() {
  479. this.$refs.upload.submit();
  480. }
  481. }
  482. };
  483. </script>