indexData.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. <template>
  2. <!-- 指标数据查询 -->
  3. <div class="indexData">
  4. <div class="box">
  5. <div class="box-top">
  6. <el-form
  7. style="overflow: hidden;"
  8. :style="filterForm.show ? null : { height: '0px' }"
  9. size="mini"
  10. label-width="70px"
  11. >
  12. <el-row>
  13. <el-col :span="6">
  14. <el-form-item label="时间粒度">
  15. <el-select
  16. filterable clearable
  17. v-model="filterForm.data.timegranid"
  18. placeholder=""
  19. style="width: 100%;"
  20. >
  21. <el-option
  22. v-for="item of nameObj.timegranid.arr"
  23. :key="item.id"
  24. :value="item.id"
  25. :label="item.name"
  26. ></el-option>
  27. </el-select>
  28. </el-form-item>
  29. </el-col>
  30. <el-col :span="6">
  31. <el-form-item label="时间">
  32. <!-- <zj-timegran-date
  33. v-model="filterForm.data.clock"
  34. style="width: 100%;"
  35. :type="'daterange'"
  36. :timegranId="filterForm.data.timegranid"
  37. :oneFoo="getTableData"
  38. :defaultOffset="-1"
  39. ></zj-timegran-date> -->
  40. <el-date-picker
  41. v-model="filterForm.data.clock"
  42. style="width: 100%;"
  43. :type="filterForm.data.timegranid === 'DAY' ? 'date' : filterForm.data.timegranid.toLowerCase()"
  44. ></el-date-picker>
  45. </el-form-item>
  46. </el-col>
  47. <el-col :span="6">
  48. <el-form-item label="工序">
  49. <el-select
  50. filterable clearable
  51. multiple
  52. collapse-tags
  53. v-model="filterForm.data.workprocid"
  54. placeholder=""
  55. :disabled="filterForm.disabled.workprocid"
  56. style="width: 100%;"
  57. >
  58. <el-option
  59. v-for="item of nameObj.workprocid.arr"
  60. :key="item.id"
  61. :value="item.id"
  62. :label="item.name"
  63. ></el-option>
  64. </el-select>
  65. </el-form-item>
  66. </el-col>
  67. <el-col :span="6">
  68. <el-form-item label="能介">
  69. <el-select
  70. filterable clearable
  71. multiple
  72. collapse-tags
  73. v-model="filterForm.data.energyid"
  74. placeholder=""
  75. style="width: 100%;"
  76. >
  77. <el-option
  78. v-for="item of nameObj.energyid.arr"
  79. :key="item.id"
  80. :value="item.id"
  81. :label="item.name"
  82. ></el-option>
  83. </el-select>
  84. </el-form-item>
  85. </el-col>
  86. </el-row>
  87. <el-row>
  88. <el-col :span="6">
  89. <el-form-item label="指标类型" prop="indextype">
  90. <el-select
  91. filterable clearable
  92. multiple
  93. collapse-tags
  94. style="width: 100%;"
  95. v-model="filterForm.data.indextype"
  96. >
  97. <el-option
  98. v-for="item of nameObj.indextype.arr"
  99. :key="item.id"
  100. :value="item.id"
  101. :label="item.name"
  102. ></el-option>
  103. </el-select>
  104. </el-form-item>
  105. </el-col>
  106. </el-row>
  107. </el-form>
  108. <div class="box-top-gjl">
  109. <div style="float:right; text-align: right;">
  110. <el-button
  111. class="button"
  112. type="primary"
  113. size="mini"
  114. icon="el-icon-search"
  115. v-privilege="activeMenu + 'QUERY'"
  116. @click="getTableData(1)"
  117. >查询</el-button>
  118. <el-button
  119. class="button"
  120. type="primary"
  121. size="mini"
  122. icon="el-icon-refresh"
  123. v-privilege="activeMenu + 'QUERY'"
  124. @click="tableDataCancel();"
  125. >重置</el-button>
  126. <el-button
  127. size="mini"
  128. :icon="filterForm.show ? 'el-icon-caret-top' : 'el-icon-caret-bottom'"
  129. :title="filterForm.show ? '收起搜索区' : '展开搜索区'"
  130. @click="filterForm.show = !filterForm.show;
  131. $nextTick(() => {
  132. singleTableHeight = getRoleHeight($refs['singleTable'].$el) - 45;
  133. }
  134. );"
  135. >{{ filterForm.show ? '收起' : '展开' }}</el-button>
  136. </div>
  137. </div>
  138. </div>
  139. <div class="box-bottom">
  140. <el-table
  141. stripe
  142. id="singleTable"
  143. ref="singleTable"
  144. :data="tableData"
  145. v-loading="tableLoading"
  146. style="width: 100%;"
  147. :height="singleTableHeight"
  148. border
  149. size="mini"
  150. highlight-current-row
  151. show-summary
  152. :summary-method="getSummaries">
  153. <el-table-column type="index" align="center" label="序号" width="40px"></el-table-column>
  154. <el-table-column
  155. sortable
  156. prop="timegranid"
  157. label="时间粒度"
  158. width="75px"
  159. :show-overflow-tooltip="true"
  160. >
  161. <template slot-scope="scope">
  162. <span>{{ nameObj.timegranid.obj[scope.row.timegranid] ? nameObj.timegranid.obj[scope.row.timegranid] : scope.row.timegranid }}</span>
  163. </template>
  164. </el-table-column>
  165. <el-table-column
  166. sortable
  167. prop="clock"
  168. label="时间"
  169. width="78px"
  170. :show-overflow-tooltip="true"
  171. ></el-table-column>
  172. <el-table-column
  173. sortable
  174. prop="indextype"
  175. label="指标类型"
  176. width="110px"
  177. :show-overflow-tooltip="true"
  178. >
  179. <template slot-scope="scope">
  180. <span>{{ nameObj.indextype.obj[scope.row.indextype] ? nameObj.indextype.obj[scope.row.indextype] : scope.row.indextype }}</span>
  181. </template>
  182. </el-table-column>
  183. <el-table-column
  184. sortable
  185. prop="workprocid"
  186. label="工序"
  187. width="120px"
  188. :show-overflow-tooltip="true"
  189. :sort-by="function(row, index) { return sortFoo(row, index, 'workprocid') }"
  190. >
  191. <template slot-scope="scope">
  192. <span>{{ nameObj.workprocid.obj[scope.row.workprocid] ? nameObj.workprocid.obj[scope.row.workprocid] : scope.row.workprocid }}</span>
  193. </template>
  194. </el-table-column>
  195. <el-table-column
  196. sortable
  197. prop="energyid"
  198. label="能介"
  199. width="85px"
  200. :show-overflow-tooltip="true"
  201. :sort-by="function(row, index) { return sortFoo(row, index, 'energyid') }"
  202. >
  203. <template slot-scope="scope">
  204. <span>{{ nameObj.energyid.obj[scope.row.energyid] ? nameObj.energyid.obj[scope.row.energyid] : scope.row.energyid }}</span>
  205. </template>
  206. </el-table-column>
  207. <el-table-column
  208. sortable
  209. prop="itemname"
  210. label="实绩项目名称"
  211. min-width="235px"
  212. :show-overflow-tooltip="true"
  213. ></el-table-column>
  214. <el-table-column
  215. sortable
  216. prop="cnsj"
  217. label="厂内实绩"
  218. min-width="120px"
  219. :show-overflow-tooltip="true"
  220. ></el-table-column>
  221. <el-table-column
  222. sortable
  223. prop="cnbz"
  224. label="厂内标准"
  225. min-width="120px"
  226. :show-overflow-tooltip="true"
  227. >
  228. <template slot-scope="scope">
  229. <span v-if="scope.row.cnbz === 0 || scope.row.cnbz"
  230. :class="{color_w: scope.row.cnsj > scope.row.cnbzwv}">
  231. {{scope.row.cnbz}}
  232. </span>
  233. <span v-else>-</span>
  234. </template>
  235. </el-table-column>
  236. <el-table-column
  237. sortable
  238. prop="gjbz"
  239. label="国家标准"
  240. min-width="120px"
  241. :show-overflow-tooltip="true"
  242. >
  243. <template slot-scope="scope">
  244. <span v-if="scope.row.gjbz === 0 || scope.row.gjbz"
  245. :class="{color_w: scope.row.cnsj > scope.row.gjbzwv}">
  246. {{scope.row.gjbz}}
  247. </span>
  248. <span v-else>-</span>
  249. </template>
  250. </el-table-column>
  251. <el-table-column
  252. sortable
  253. prop="hybz"
  254. label="行业标准"
  255. min-width="120px"
  256. :show-overflow-tooltip="true"
  257. >
  258. <template slot-scope="scope">
  259. <span v-if="scope.row.hybz === 0 || scope.row.hybz"
  260. :class="{color_w: scope.row.cnsj > scope.row.hybzwv}">
  261. {{scope.row.hybz}}
  262. </span>
  263. <span v-else>-</span>
  264. </template>
  265. </el-table-column>
  266. <el-table-column
  267. sortable
  268. prop="factoryid"
  269. label="行准工厂"
  270. width="90px"
  271. :show-overflow-tooltip="true"
  272. >
  273. <template slot-scope="scope">
  274. <span>{{ nameObj.factoryid.obj[scope.row.factoryid] ? nameObj.factoryid.obj[scope.row.factoryid] : '-' }}</span>
  275. </template>
  276. </el-table-column>
  277. <el-table-column
  278. sortable
  279. prop="unitid"
  280. label="单位"
  281. width="99px"
  282. :show-overflow-tooltip="true"
  283. >
  284. <template slot-scope="scope">
  285. <span>{{ nameObj.unitid.obj[scope.row.unitid] ? nameObj.unitid.obj[scope.row.unitid] : scope.row.unitid }}</span>
  286. </template>
  287. </el-table-column>
  288. </el-table>
  289. <el-pagination
  290. layout="total, sizes, prev, pager, next, jumper"
  291. :total="total"
  292. :page-sizes="[10, 20, 50, 100, 500, 1000]"
  293. :page-size="pageSize"
  294. :current-page.sync="pageNum"
  295. @size-change="tableSizeChange"
  296. @current-change="getTableData()"
  297. style="text-align: right;margin-top: 10px;"
  298. ></el-pagination>
  299. </div>
  300. </div>
  301. </div>
  302. </template>
  303. <script>
  304. import { zCheckNumber1 } from '~/utils/validator.js'
  305. import store from '@/store/index.js';
  306. import timegranDate from '~/components/zg/timegranDate.vue'
  307. import {formatDate, XtcommonSummaries} from '@/utils/util.js';
  308. export default {
  309. name: 'indexData',
  310. components: {
  311. 'zj-timegran-date': timegranDate
  312. },
  313. data () {
  314. let start = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() - 1);
  315. return {
  316. activeMenu: '',
  317. filterForm: {
  318. show: true,
  319. data: {
  320. timegranid: 'DAY',
  321. clock: formatDate(start, 'yyyy-MM-dd'),
  322. workprocid: [],
  323. energyid: [],
  324. propertyid: '',
  325. itemid: '',
  326. itemname: '',
  327. indextype: []
  328. },
  329. rules: {
  330. },
  331. disabled: {
  332. workprocid: false
  333. }
  334. },
  335. tableFormRules: {
  336. numbers: [
  337. { validator: zCheckNumber1, trigger: 'change' }
  338. ]
  339. },
  340. pageNum: 1,
  341. pageSize: 50,
  342. total: 0,
  343. singleTableHeight: 100,
  344. tableData: [],
  345. nameObj: {
  346. timegranid: {
  347. obj: {'DAY': '日', 'MONTH': '月', 'YEAR': '年'},
  348. arr: [{id: 'DAY', name: '日'}, {id: 'MONTH', name: '月'}, {id: 'YEAR', name: '年'}]
  349. },
  350. workprocid: {
  351. obj: {},
  352. arr: []
  353. },
  354. energyid: {
  355. obj: {},
  356. arr: []
  357. },
  358. propertyid: {
  359. obj: {},
  360. arr: []
  361. },
  362. unitid: {
  363. obj: {},
  364. arr: []
  365. },
  366. indextype: {
  367. obj: {},
  368. arr: []
  369. },
  370. factoryid: {
  371. obj: {},
  372. arr: []
  373. }
  374. },
  375. loading: false,
  376. tableLoading: false
  377. }
  378. },
  379. created () {
  380. this.activeMenu = window.localStorage.getItem('activeMenu');
  381. },
  382. mounted () {
  383. let that = this;
  384. window.PEDataObj = {
  385. // 将数据绑定到window上,供main页面使用
  386. vm: that,
  387. // tableArr:用于导出成Excel的表格的信息
  388. tableArr: [
  389. {
  390. name: '',
  391. id: 'singleTable'
  392. }
  393. ]
  394. };
  395. that.$nextTick(() => {
  396. // 立即获取的height有一定偏差,通过setTimeout延迟来解决
  397. setTimeout(() => {
  398. that.singleTableHeight = that.getRoleHeight(that.$refs['singleTable'].$el) - 45;
  399. }, 1);
  400. });
  401. // that.store.dispatch('getUserInfo').then((res) => {
  402. // that.userInfo.data = res.data;
  403. // });
  404. // 接收路由参数
  405. if (that.$route.query.workprocid) {
  406. that.filterForm.disabled.workprocid = true;
  407. that.filterForm.data.workprocid = that.$route.query.workprocid.split(',');
  408. }
  409. that.getWorkprocIdData();
  410. that.getEnergyIdData();
  411. that.getPropertyIdData();
  412. that.getUnitIdData();
  413. that.getFactoryIdData();
  414. that.getType();
  415. // that.getTableData();
  416. },
  417. methods: {
  418. // 计算树区域高度
  419. getRoleHeight (dom) {
  420. return window.innerHeight - dom.offsetTop;
  421. },
  422. // 用于表格特殊列的过滤方法(:sort-by="function(row, index) { return sortFoo() }")
  423. sortFoo (row, index, objName, name) {
  424. name = name || objName;
  425. let s = this.nameObj[objName].obj[row[name]] ? this.nameObj[objName].obj[row[name]] : row[name];
  426. return s;
  427. },
  428. // 自定义的表格合计方法:只给指定列进行合计
  429. getSummaries (param) {
  430. const prop = []; // 合计列绑定的prop
  431. return XtcommonSummaries(param, prop);
  432. },
  433. // 获取工序(指标)
  434. getWorkprocIdData () {
  435. let that = this
  436. let url = 'pass/ems/v1/trmworkprocs/getIdAndName?isreal=1';
  437. that.axios.get(url)
  438. .then(function (res) {
  439. if (res.code === '0') {
  440. let arr = [];
  441. let obj = {};
  442. for (let item of res.data) {
  443. arr.push({
  444. id: item.id,
  445. name: item.name
  446. })
  447. obj[item.id] = item.name;
  448. }
  449. that.nameObj.workprocid.arr = arr;
  450. that.nameObj.workprocid.obj = obj;
  451. } else {
  452. that.$message.error(res.message);
  453. }
  454. });
  455. },
  456. // 获取能介
  457. getEnergyIdData () {
  458. let that = this
  459. let url = 'pass/ems/v1/trmenergys/selectNameAndId/';
  460. that.axios.get(url)
  461. .then(function (res) {
  462. if (res.code === '0') {
  463. let arr = [];
  464. let obj = {};
  465. for (let item of res.data) {
  466. arr.push({
  467. id: item.id,
  468. name: item.name
  469. })
  470. obj[item.id] = item.name;
  471. }
  472. that.nameObj.energyid.arr = arr;
  473. that.nameObj.energyid.obj = obj;
  474. } else {
  475. that.$message.error(res.message);
  476. }
  477. });
  478. },
  479. // 获取属性
  480. getPropertyIdData () {
  481. let that = this
  482. let url = 'pass/ems/v1/trmenergypropertys/getidandname/';
  483. that.axios.get(url)
  484. .then(function (res) {
  485. if (res.code === '0') {
  486. let arr = [];
  487. let obj = {};
  488. for (let item of res.data) {
  489. arr.push({
  490. id: item.id,
  491. name: item.name
  492. })
  493. obj[item.id] = item.name;
  494. }
  495. that.nameObj.propertyid.arr = arr;
  496. that.nameObj.propertyid.obj = obj;
  497. } else {
  498. that.$message.error(res.message);
  499. }
  500. });
  501. },
  502. // 获取标准计量单位
  503. getUnitIdData () {
  504. let that = this
  505. let url = 'pass/ems/v1/trmunits/getIdAndName';
  506. that.axios.get(url)
  507. .then(function (res) {
  508. if (res.code === '0') {
  509. let arr = [];
  510. let obj = {};
  511. for (let item of res.data) {
  512. arr.push({
  513. id: item.id,
  514. name: item.name
  515. })
  516. obj[item.id] = item.name;
  517. if (item.name === '吨') {
  518. that.nameObj.unitid.defaults = that.nameObj.unitid.defaults ? that.nameObj.unitid.defaults : item.id;
  519. }
  520. }
  521. that.nameObj.unitid.arr = arr;
  522. that.nameObj.unitid.obj = obj;
  523. } else {
  524. that.$message.error(res.message);
  525. }
  526. });
  527. },
  528. // 获取表格中的数据
  529. getTableData (pageNum) {
  530. let that = this;
  531. let clock;
  532. if (!that.filterForm.data.clock) {
  533. that.$message.error('请选择日期');
  534. }
  535. if (that.filterForm.data.timegranid === 'MONTH') {
  536. clock = formatDate(that.filterForm.data.clock, 'yyyy-MM');
  537. } else if (that.filterForm.data.timegranid === 'YEAR') {
  538. clock = formatDate(that.filterForm.data.clock, 'yyyy');
  539. } else {
  540. clock = formatDate(that.filterForm.data.clock, 'yyyy-MM-dd');
  541. }
  542. let params = {
  543. timegranid: that.filterForm.data.timegranid,
  544. clock: clock,
  545. workprocid: that.filterForm.data.workprocid.toString(),
  546. energyid: that.filterForm.data.energyid.toString(),
  547. itemid: that.filterForm.data.itemid,
  548. indextype: that.filterForm.data.indextype.toString()
  549. };
  550. that.pageNum = pageNum || that.pageNum;
  551. that.tableLoading = true;
  552. let url = 'pass/ems/v1/trmindexvalues/getIndexData/?pageNum=' + that.pageNum + '&pageSize=' + that.pageSize;
  553. that.axios.get(url, {
  554. params: params
  555. })
  556. .then(function (res) {
  557. if (res.code === '0') {
  558. let arr = [];
  559. for (let i = 0; i < res.data.list.length; i++) {
  560. let item = res.data.list[i];
  561. arr.push({
  562. seq: i,
  563. itemid: item.ITEMID,
  564. clock: item.CLOCK,
  565. timegranid: item.TIMEGRANID,
  566. itemname: item.ITEMNAME,
  567. unitid: item.UNITID,
  568. cnsj: item.CNSJ,
  569. cnbz: item.CNBZ,
  570. cnbzwv: item.CNBZWV,
  571. gjbz: item.GJBZ,
  572. gjbzwv: item.GJBZWV,
  573. hybz: item.HYBZ,
  574. hybzwv: item.HYBZWV,
  575. workprocid: item.WORKPROCID,
  576. energyid: item.ENERGYID,
  577. factoryid: item.FACTORYID,
  578. indextype: item.INDEXTYPE
  579. })
  580. }
  581. that.tableData = arr;
  582. that.total = res.data.total;
  583. } else {
  584. that.$message.error(res.message);
  585. }
  586. that.tableLoading = false;
  587. }).catch(function () {
  588. that.tableLoading = false;
  589. });
  590. },
  591. // 改变表格显示条数
  592. tableSizeChange (val) {
  593. let that = this;
  594. that.pageSize = val;
  595. that.getTableData(1);
  596. },
  597. // 重置搜索
  598. tableDataCancel () {
  599. let that = this;
  600. that.filterForm.data.timegranid = 'DAY';
  601. that.filterForm.data.clock = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() - 1);
  602. that.filterForm.data.workprocid = [];
  603. that.filterForm.data.energyid = [];
  604. that.filterForm.data.indextype = [];
  605. that.filterForm.data.propertyid = '';
  606. that.filterForm.data.itemid = '';
  607. that.filterForm.data.itemname = '';
  608. // that.getTableData(1);
  609. },
  610. // 分类获取所有指标类型
  611. getType () {
  612. let that = this
  613. let url = 'pass/ems/v1/trmindextypes/?pageSize=1000&indexcol=INDEXTYPE';
  614. that.axios.get(url).then(function (res) {
  615. if (res.code === '0') {
  616. let arr = [];
  617. let obj = {};
  618. for (let item of res.data.list) {
  619. arr.push({
  620. id: item.indexid,
  621. name: item.indexname
  622. })
  623. obj[item.indexid] = item.indexname;
  624. }
  625. that.nameObj.indextype.arr = arr;
  626. that.nameObj.indextype.obj = obj;
  627. } else {
  628. that.$message.error(res.message);
  629. }
  630. });
  631. },
  632. // 获取工厂
  633. getFactoryIdData () {
  634. let that = this
  635. let url = 'pass/ems/v1/trmfactorys/getIAndName';
  636. that.axios.get(url)
  637. .then(function (res) {
  638. if (res.code === '0') {
  639. let arr = [];
  640. let obj = {};
  641. for (let item of res.data) {
  642. arr.push({
  643. id: item.id,
  644. name: item.name
  645. })
  646. obj[item.id] = item.name;
  647. }
  648. that.nameObj.factoryid.arr = arr;
  649. that.nameObj.factoryid.obj = obj;
  650. } else {
  651. that.$message.error(res.message);
  652. }
  653. });
  654. }
  655. }
  656. }
  657. </script>
  658. <style lang="less">
  659. .indexData {
  660. min-width: 700px;
  661. height: 100%;
  662. .box {
  663. height: 100%;
  664. padding: 15px 15px 0 15px;
  665. .box-top {
  666. .el-form-item {
  667. margin-bottom: 7px;
  668. }
  669. .box-top-gjl {
  670. overflow: hidden;
  671. padding: 7px 0;
  672. border-top: 1px solid #ccc;
  673. // margin-bottom: 6px;
  674. }
  675. }
  676. }
  677. .el-table__body .el-form-item--mini.el-form-item {
  678. margin: 0px;
  679. .error {
  680. overflow: hidden;
  681. color: #f56c6c;
  682. font-size: 12px;
  683. line-height: 1;
  684. }
  685. }
  686. .el-table__body input {
  687. font-weight: normal;
  688. padding-left: 8px;
  689. padding-right: 25px;
  690. }
  691. .color_w {
  692. color: red;
  693. }
  694. }
  695. </style>