index.vue 19 KB

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