index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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('污染物名称')" label-width="50" prop="emissionname">
  5. <el-input
  6. v-model="queryParams.emissionname"
  7. :placeholder="$t('请输入') + $t('污染物名称')"
  8. clearable
  9. size="small"
  10. @input="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item :label="$t('类别')" prop="category">
  14. <el-select v-model="queryParams.category" :placeholder="$t('请选择') + $t('类别')" clearable size="small" @change="handleQuery">
  15. <el-option
  16. v-for="dict in categoryOptions"
  17. :key="dict.dictValue"
  18. :label="dict.dictLabel"
  19. :value="dict.dictValue"
  20. />
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item>
  24. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">{{ $t('搜索') }}</el-button>
  25. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('重置') }}</el-button>
  26. </el-form-item>
  27. </el-form>
  28. <el-row :gutter="10" class="mb8">
  29. <el-col :span="1.5">
  30. <el-button
  31. type="primary"
  32. icon="el-icon-plus"
  33. size="mini"
  34. @click="handleAdd"
  35. >{{ $t('新增') }}</el-button>
  36. </el-col>
  37. <el-col :span="1.5">
  38. <el-button
  39. type="success"
  40. icon="el-icon-edit"
  41. size="mini"
  42. :disabled="single"
  43. @click="handleUpdate"
  44. >{{ $t('修改') }}</el-button>
  45. </el-col>
  46. <el-col :span="1.5">
  47. <el-button
  48. type="danger"
  49. icon="el-icon-delete"
  50. size="mini"
  51. :disabled="multiple"
  52. @click="handleDelete"
  53. >{{ $t('删除') }}</el-button>
  54. </el-col>
  55. <el-col :span="1.5">
  56. <el-button
  57. type="info"
  58. icon="el-icon-upload2"
  59. size="mini"
  60. @click="handleImport"
  61. >{{ $t('导入') }}</el-button>
  62. </el-col>
  63. <el-col :span="1.5">
  64. <el-button
  65. type="warning"
  66. icon="el-icon-download"
  67. size="mini"
  68. @click="handleExport"
  69. >{{ $t('导出') }}</el-button>
  70. </el-col>
  71. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  72. </el-row>
  73. <el-table v-loading="loading" :data="environapprcontList" @selection-change="handleSelectionChange" :height="clientHeight" border>
  74. <el-table-column type="selection" width="55" align="center" />
  75. <el-table-column :label="$t('污染物名称')" align="center" prop="emissionname" :show-overflow-tooltip="true"/>
  76. <el-table-column :label="$t('类别')" align="center" prop="category" :formatter="categoryFormat" />
  77. <el-table-column :label="$t('年份')" align="center" prop="year" width="100">
  78. </el-table-column>
  79. <el-table-column :label="$t('排放量')" align="center" prop="emissions" :show-overflow-tooltip="true"/>
  80. <el-table-column :label="$t('详细内容')" align="center" prop="contents" :show-overflow-tooltip="true"/>
  81. <el-table-column :label="$t('操作')" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
  82. <template slot-scope="scope">
  83. <el-button
  84. size="mini"
  85. type="text"
  86. icon="el-icon-edit"
  87. @click="handleUpdate(scope.row)"
  88. >{{ $t('修改') }}</el-button>
  89. <el-button
  90. size="mini"
  91. type="text"
  92. icon="el-icon-delete"
  93. @click="handleDelete(scope.row)"
  94. >{{ $t('删除') }}</el-button>
  95. </template>
  96. </el-table-column>
  97. </el-table>
  98. <pagination
  99. v-show="total>0"
  100. :total="total"
  101. :page.sync="queryParams.pageNum"
  102. :limit.sync="queryParams.pageSize"
  103. @pagination="getList"
  104. />
  105. <!-- 添加或修改环保批文主要内容对话框 -->
  106. <el-dialog :close-on-click-modal="false" v-dialogDrag :title="title" :visible.sync="open" width="500px" append-to-body>
  107. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  108. <el-form-item :label="$t('污染物名称')" prop="emissionname">
  109. <el-input v-model="form.emissionname" :placeholder="$t('请输入') + $t('污染物名称')" />
  110. </el-form-item>
  111. <el-form-item :label="$t('类别')" prop="category">
  112. <el-select v-model="form.category" :placeholder="$t('请选择') + $t('类别')">
  113. <el-option
  114. v-for="dict in categoryOptions"
  115. :key="dict.dictValue"
  116. :label="dict.dictLabel"
  117. :value="dict.dictValue"
  118. ></el-option>
  119. </el-select>
  120. </el-form-item>
  121. <el-form-item :label="$t('年份')" prop="year">
  122. <el-date-picker clearable size="small" style="width: 200px"
  123. v-model="form.year"
  124. type="year"
  125. :placeholder="$t('选择') + $t('年份')">
  126. </el-date-picker>
  127. </el-form-item>
  128. <el-form-item :label="$t('排放量')" prop="emissions">
  129. <el-input v-model="form.emissions" :placeholder="$t('请输入') + $t('排放量')" />
  130. </el-form-item>
  131. <el-form-item :label="$t('详细内容')" prop="contents">
  132. <el-input v-model="form.contents" type="textarea" :placeholder="$t('请输入') + $t('内容')" />
  133. </el-form-item>
  134. </el-form>
  135. <div slot="footer" class="dialog-footer">
  136. <el-button type="primary" @click="submitForm">{{ $t('确 定') }}</el-button>
  137. <el-button @click="cancel">{{ $t('取 消') }}</el-button>
  138. </div>
  139. </el-dialog>
  140. <!-- 用户导入对话框 -->
  141. <el-dialog :close-on-click-modal="false" v-dialogDrag :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  142. <el-upload
  143. ref="upload"
  144. :limit="1"
  145. accept=".xlsx, .xls"
  146. :headers="upload.headers"
  147. :action="upload.url"
  148. :disabled="upload.isUploading"
  149. :on-progress="handleFileUploadProgress"
  150. :on-success="handleFileSuccess"
  151. :auto-upload="false"
  152. drag
  153. >
  154. <i class="el-icon-upload"></i>
  155. <div class="el-upload__text">
  156. {{ $t('将文件拖到此处,或') }}
  157. <em>{{ $t('点击上传') }}</em>
  158. </div>
  159. <div class="el-upload__tip" slot="tip">
  160. <!--<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据-->
  161. <el-link type="info" style="font-size:12px" @click="importTemplate">{{ $t('下载模板') }}</el-link>
  162. </div>
  163. <form ref="downloadFileForm" :action="upload.downloadAction" target="FORMSUBMIT">
  164. <input name="type" :value="upload.type" hidden />
  165. </form>
  166. <div class="el-upload__tip" style="color:red" slot="tip">{{ $t('提示:仅允许导入“xls”或“xlsx”格式文件!') }}</div>
  167. </el-upload>
  168. <div slot="footer" class="dialog-footer">
  169. <el-button type="primary" @click="submitFileForm">{{ $t('确 定') }}</el-button>
  170. <el-button @click="upload.open = false">{{ $t('取 消') }}</el-button>
  171. </div>
  172. </el-dialog>
  173. </div>
  174. </template>
  175. <script>
  176. import { listEnvironapprcont, getEnvironapprcont, delEnvironapprcont, addEnvironapprcont, updateEnvironapprcont, exportEnvironapprcont } from "@/api/ehs/environapprcont";
  177. import { treeselect } from "@/api/system/dept";
  178. import { getToken } from "@/utils/auth";
  179. import Treeselect from "@riophae/vue-treeselect";
  180. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  181. export default {
  182. name: "Environapprcont",
  183. components: { Treeselect },
  184. data() {
  185. return {
  186. // 遮罩层
  187. loading: true,
  188. // 选中数组
  189. ids: [],
  190. // 非单个禁用
  191. single: true,
  192. // 非多个禁用
  193. multiple: true,
  194. // 显示搜索条件
  195. showSearch: false,
  196. // 总条数
  197. total: 0,
  198. // 环保批文主要内容表格数据
  199. environapprcontList: [],
  200. // 弹出层标题
  201. title: "",
  202. // 部门树选项
  203. deptOptions: undefined,
  204. clientHeight:300,
  205. // 是否显示弹出层
  206. open: false,
  207. // 类别字典
  208. categoryOptions: [],
  209. // 用户导入参数
  210. upload: {
  211. //下载模板请求地址
  212. downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
  213. //下载模板类型
  214. type: "environapprcont",
  215. // 是否显示弹出层(用户导入)
  216. open: false,
  217. // 弹出层标题(用户导入)
  218. title: "",
  219. // 是否禁用上传
  220. isUploading: false,
  221. // 是否更新已经存在的用户数据
  222. updateSupport: 0,
  223. // 设置上传的请求头部
  224. headers: { Authorization: "Bearer " + getToken() },
  225. // 上传的地址
  226. url: process.env.VUE_APP_BASE_API + "/ehs/environapprcont/importData"
  227. },
  228. // 查询参数
  229. queryParams: {
  230. pageNum: 1,
  231. pageSize: 20,
  232. emissionname: null,
  233. category: null,
  234. year: null,
  235. emissions: null,
  236. remarks: null,
  237. },
  238. // 表单参数
  239. form: {
  240. pid: null
  241. },
  242. // 表单校验
  243. rules: {
  244. }
  245. };
  246. },
  247. watch: {
  248. // 根据名称筛选部门树
  249. deptName(val) {
  250. this.$refs.tree.filter(val);
  251. }
  252. },
  253. created() {
  254. //设置表格高度对应屏幕高度
  255. this.$nextTick(() => {
  256. this.clientHeight = (document.body.clientHeight - 80) * 0.8
  257. })
  258. this.queryParams.pid = this.$route.params && this.$route.params.tableId;
  259. this.getList();
  260. this.getTreeselect();
  261. this.getDicts("WASTE_CATEGORY").then(response => {
  262. this.categoryOptions = response.data;
  263. });
  264. },
  265. methods: {
  266. /** 查询环保批文主要内容列表 */
  267. getList() {
  268. this.loading = true;
  269. listEnvironapprcont(this.queryParams).then(response => {
  270. this.environapprcontList = response.rows;
  271. this.total = response.total;
  272. this.loading = false;
  273. });
  274. },
  275. /** 查询部门下拉树结构 */
  276. getTreeselect() {
  277. treeselect().then(response => {
  278. this.deptOptions = response.data;
  279. });
  280. },
  281. // 类别字典翻译
  282. categoryFormat(row, column) {
  283. return this.selectDictLabel(this.categoryOptions, row.category);
  284. },
  285. // 取消按钮
  286. cancel() {
  287. this.open = false;
  288. this.reset();
  289. },
  290. // 表单重置
  291. reset() {
  292. this.form = {
  293. id: null,
  294. emissionname: null,
  295. category: null,
  296. year: null,
  297. emissions: null,
  298. contents: null,
  299. delFlag: null,
  300. createrCode: null,
  301. createdate: null,
  302. updaterCode: null,
  303. updatedate: null,
  304. deptId: null,
  305. remarks: null,
  306. pid: null
  307. };
  308. this.resetForm("form");
  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. handleAdd() {
  328. this.reset();
  329. this.open = true;
  330. this.title = this.$t('新增') + " " + this.$t('环保批文') + " " + this.$t('主要内容');
  331. },
  332. /** 修改按钮操作 */
  333. handleUpdate(row) {
  334. this.reset();
  335. const id = row.id || this.ids
  336. getEnvironapprcont(id).then(response => {
  337. this.form = response.data;
  338. this.open = true;
  339. this.title = this.$t('修改') + this.$t('环保批文') + " " + this.$t('主要内容');
  340. });
  341. },
  342. /** 提交按钮 */
  343. submitForm() {
  344. this.$refs["form"].validate(valid => {
  345. if (valid) {
  346. if (this.form.id != null) {
  347. updateEnvironapprcont(this.form).then(response => {
  348. this.msgSuccess(this.$t('修改成功'));
  349. this.open = false;
  350. this.getList();
  351. });
  352. } else {
  353. this.form.pid = this.$route.params.tableId
  354. addEnvironapprcont(this.form).then(response => {
  355. this.msgSuccess(this.$t('新增成功'));
  356. this.open = false;
  357. this.getList();
  358. });
  359. }
  360. }
  361. });
  362. },
  363. /** 删除按钮操作 */
  364. handleDelete(row) {
  365. const ids = row.id || this.ids;
  366. this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
  367. confirmButtonText: this.$t('确定'),
  368. cancelButtonText: this.$t('取消'),
  369. type: "warning"
  370. }).then(function() {
  371. return delEnvironapprcont(ids);
  372. }).then(() => {
  373. this.getList();
  374. this.msgSuccess(this.$t('删除成功'));
  375. })
  376. },
  377. /** 导出按钮操作 */
  378. handleExport() {
  379. const queryParams = this.queryParams;
  380. this.$confirm(this.$t('是否确认导出所有环保批文主要内容数据项?'), this.$t('警告'), {
  381. confirmButtonText: this.$t('确定'),
  382. cancelButtonText: this.$t('取消'),
  383. type: "warning"
  384. }).then(function() {
  385. return exportEnvironapprcont(queryParams);
  386. }).then(response => {
  387. this.download(response.msg);
  388. })
  389. },
  390. /** 导入按钮操作 */
  391. handleImport() {
  392. this.upload.title = this.$t('用户导入');
  393. this.upload.open = true;
  394. },
  395. /** 下载模板操作 */
  396. importTemplate() {
  397. this.$refs['downloadFileForm'].submit()
  398. },
  399. // 文件上传中处理
  400. handleFileUploadProgress(event, file, fileList) {
  401. this.upload.isUploading = true;
  402. },
  403. // 文件上传成功处理
  404. handleFileSuccess(response, file, fileList) {
  405. this.upload.open = false;
  406. this.upload.isUploading = false;
  407. this.$refs.upload.clearFiles();
  408. if (response.data[0] != null) {
  409. this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据') + "," + this.$t('第') + response.data + this.$t('行数据出现错误导入失败')+"。", this.$t('导入结果'), { dangerouslyUseHTMLString: true });
  410. }else {
  411. this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据'), this.$t('导入结果'), { dangerouslyUseHTMLString: true });
  412. }
  413. this.getList();
  414. },
  415. // 提交上传文件
  416. submitFileForm() {
  417. this.$refs.upload.submit();
  418. }
  419. }
  420. };
  421. </script>