list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="手动集抄" @clickLeft="back">
  4. <template slot="right">
  5. <u-button type="success" size="small" class="u-reset-button" @click="$refs.treePicker._show()"
  6. text="选择分类"></u-button>
  7. </template>
  8. </uni-nav-bar>
  9. <view class="top-wrapper">
  10. <uni-section>
  11. <zxz-uni-data-select :localdata="energyConsumingUnitList" v-model="energyClassificationCode"
  12. dataValue='value' style="width: 500rpx;" dataKey="label" filterable
  13. format='{label}'></zxz-uni-data-select>
  14. </uni-section>
  15. <button class="search_btn" @click="doSearch">搜索</button>
  16. </view>
  17. <div style="height: 100rpx; width: 475rpx"></div>
  18. <view class="wrapper">
  19. <u-list @scrolltolower="scrolltolower" class="listContent">
  20. <view v-for="(item, index) in tableList" :key="index" style="position: relative">
  21. <myCard :item="item" :index="index + 1" :btnList="btnList" :columns="columns" :title="item.code"
  22. :status="statusMap[item.status]" @goDetail="goDetail(item, 'view')"
  23. @handlePublish="handlePublish(item, 1)" @handleDelete="handleDelete(item)"
  24. @handleSubmit="handleSubmit(item)" @edit="goDetail(item, 'edit')">
  25. </myCard>
  26. </view>
  27. <view style="width: 100%; height: 40rpx"></view>
  28. <view style="margin-top: 20vh" v-if="tableList.length == 0">
  29. <u-empty iconSize="150" textSize="32" text="暂无数据"> </u-empty>
  30. </view>
  31. </u-list>
  32. </view>
  33. <u-toast ref="uToast"></u-toast>
  34. <ba-tree-picker ref="treePicker" :multiple="false" @select-change="confirm" :localdata="listData" valueKey="id"
  35. textKey="name" childrenKey="children" />
  36. <workOrderReport ref="workOrderReportRef" :pageName="pageName" @refresh="successInit"></workOrderReport>
  37. <view class="add" @click="goDetail({},'add')">
  38. <u-icon name="plus" color="#fff"></u-icon>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import dictMixns from "@/mixins/dictMixins";
  44. import myCard from "./components/myCard.vue";
  45. import {
  46. getTreeByPid
  47. } from "@/api/classifyManage";
  48. import workOrderReport from "./components/workOrderReport.vue";
  49. import {
  50. getList,
  51. deleteById,
  52. updatePublishStatus
  53. } from "@/api/centralizedMeterReading/index";
  54. import {
  55. parameterGetByCode
  56. } from '@/api/mainData/index.js'
  57. import {
  58. energyConsumingUnitList
  59. } from '@/enum/dict.js';
  60. import {
  61. processInstanceCreateAPI,
  62. processInstancePage
  63. } from '@/api/wt/index.js'
  64. export default {
  65. components: {
  66. myCard,
  67. workOrderReport,
  68. },
  69. mixins: [dictMixns],
  70. props: {
  71. pageName: {
  72. default: "",
  73. },
  74. },
  75. data() {
  76. return {
  77. statusMap: {
  78. 0: "未报工",
  79. 1: "执行中",
  80. 2: "已执行",
  81. },
  82. energyConsumingUnitList,
  83. planTypeList: {
  84. productionRecords: 2,
  85. steamInjectionInspectionRecord: 3,
  86. solidWasteRecord: 4,
  87. qualityTestRecords: 5,
  88. boilerOperationRecord: 6,
  89. },
  90. columns: [
  91. [{
  92. prop: "substanceName",
  93. label: "表计设备名称",
  94. className: "perce100",
  95. }, ],
  96. [{
  97. prop: "currentMeterReadingTime",
  98. label: "本期抄表时间",
  99. className: "perce100",
  100. }, ],
  101. [{
  102. prop: "currentMeterReadingNum",
  103. label: "本期抄表数",
  104. className: "perce50",
  105. },
  106. {
  107. prop: "unit",
  108. label: "单位",
  109. className: "perce50",
  110. },
  111. ],
  112. [{
  113. prop: "meterReadingName",
  114. label: "抄表人",
  115. className: "perce100",
  116. }, ],
  117. [{
  118. prop: "meterEquipmentNumber",
  119. label: "表计设备编号",
  120. className: "perce100",
  121. }, ],
  122. [{
  123. prop: "meterType",
  124. label: "表计类型",
  125. className: "perce100",
  126. formatter: (_row) => {
  127. return this.getDictValue("表计类型", _row.meterType);
  128. },
  129. }, ],
  130. [{
  131. prop: "correlationSubstanceName",
  132. label: "关联设备",
  133. className: "perce100",
  134. }, ],
  135. [{
  136. prop: "areaName",
  137. label: "区域",
  138. className: "perce100",
  139. }, ],
  140. [{
  141. prop: "energyClassificationName",
  142. label: "用能分类",
  143. className: "perce100",
  144. }, ],
  145. [{
  146. prop: "energyTypeName",
  147. label: "能源名称",
  148. className: "perce100",
  149. }, ],
  150. [{
  151. prop: "approvalStatus",
  152. label: "审核状态",
  153. className: "perce50",
  154. formatter: (row) => {
  155. const reviewStatus = {
  156. 0: "未提交",
  157. 1: "审核中",
  158. 2: "已审核",
  159. 3: "审核不通过",
  160. };
  161. return reviewStatus[row.approvalStatus];
  162. },
  163. },
  164. {
  165. prop: "publishStatus",
  166. label: "发布状态",
  167. className: "perce50",
  168. formatter: (_row, _column, cellValue) => {
  169. return _row.publishStatus == 1 ?
  170. "已发布" :
  171. _row.publishStatus == 2 ?
  172. "已撤销" :
  173. "未发布";
  174. },
  175. },
  176. ],
  177. [{
  178. label: "操作:",
  179. prop: "action",
  180. type: "action",
  181. className: "perce100",
  182. }, ],
  183. ].filter((item) => !item.isNone),
  184. listData: [],
  185. tableList: [],
  186. categoryLevelId: '',
  187. energyClassificationCode: '',
  188. page: 1,
  189. size: 10,
  190. isEnd: false,
  191. keyWord: "",
  192. userInfo: {},
  193. approval: '1',
  194. };
  195. },
  196. computed: {
  197. btnList() {
  198. return [{
  199. name: "编辑",
  200. apiName: "edit",
  201. btnType: "primary",
  202. judge: [{
  203. fn: (item) => {
  204. return (
  205. [0, 3].includes(item.approvalStatus) &&
  206. item.publishStatus != 1
  207. );
  208. },
  209. }, ],
  210. },
  211. {
  212. name: "提交",
  213. apiName: "handleSubmit",
  214. btnType: "primary",
  215. judge: [{
  216. fn: (item) => {
  217. return (
  218. this.approval == 1 && [0, 3].includes(item.approvalStatus) && item
  219. .publishStatus != 1
  220. );
  221. },
  222. }, ],
  223. },
  224. {
  225. name: "删除",
  226. apiName: "handleDelete",
  227. btnType: "danger",
  228. judge: [{
  229. fn: (item) => {
  230. return (
  231. item.publishStatus != 1 && [0].includes(item.approvalStatus)
  232. );
  233. },
  234. }, ],
  235. },
  236. {
  237. name: "发布",
  238. apiName: "handlePublish",
  239. btnType: "primary",
  240. judge: [{
  241. fn: (item) => {
  242. return (
  243. item.publishStatus == 0 &&
  244. this.approval != 1
  245. );
  246. },
  247. }, ],
  248. },
  249. ];
  250. },
  251. },
  252. created() {
  253. //用能集抄人工录入审批:0不审批,1审批
  254. parameterGetByCode({
  255. code: 'ems_manual_entry_for_approval'
  256. }).then((res) => {
  257. if (res.value) {
  258. this.approval = res.value;
  259. }
  260. });
  261. this.requestDict("表计类型");
  262. getTreeByPid('29').then((res) => {
  263. this.listData = res.data;
  264. });
  265. },
  266. onLoad() {},
  267. methods: {
  268. confirm(data, name) {
  269. if (data[0]) {
  270. this.categoryLevelId = data[0].id
  271. } else {
  272. this.categoryLevelId = ''
  273. }
  274. this.doSearch()
  275. },
  276. goDetail(item, type) {
  277. this.$refs.workOrderReportRef.open(item, type);
  278. },
  279. handleDelete(row) {
  280. deleteById([row.id]).then((res) => {
  281. uni.showLoading({
  282. title: "删除成功",
  283. });
  284. this.successInit()
  285. });
  286. },
  287. async handleSubmit(row) {
  288. try {
  289. //后台不提供接口
  290. let list = await processInstancePage({
  291. pageNo: 1,
  292. pageSize: 1,
  293. reset: true,
  294. key: 'ems_remote_meter_reading'
  295. })
  296. let params = {
  297. businessId: row.id,
  298. businessKey: 'ems_remote_meter_reading',
  299. formCreateUserId: row.createUserId,
  300. processDefinitionId: list?.list[0]?.processDefinition.id,
  301. variables: {
  302. businessCode: row.substanceCode,
  303. businessName: row.substanceName,
  304. businessType: '人工录入抄表'
  305. },
  306. }
  307. await processInstanceCreateAPI(params)
  308. uni.showModal({
  309. title: `提交成功`,
  310. content: '',
  311. confirmText: '确认',
  312. showCancel: false, // 是否显示取消按钮,默认为 true
  313. success: () => {
  314. this.successInit()
  315. }
  316. })
  317. } catch {
  318. }
  319. },
  320. // 发布/撤销
  321. handlePublish(row, status) {
  322. updatePublishStatus(row.id, status).then(() => {
  323. uni.showLoading({
  324. title: "发布成功",
  325. });
  326. this.successInit()
  327. });
  328. },
  329. successInit() {
  330. uni.showLoading({
  331. title: "加载中",
  332. });
  333. let data = {
  334. pageNum: 1,
  335. size: this.tableList.length,
  336. keyword: this.keyWord,
  337. areaId: "",
  338. categoryLevelId: this.categoryLevelId,
  339. meterReadingMethod: 1,
  340. currentLoginUserId: this.userInfo.userId,
  341. energyClassificationCode: this.energyClassificationCode
  342. };
  343. getList(data)
  344. .then((res) => {
  345. this.tableList = res.list;
  346. })
  347. .then(() => {
  348. uni.hideLoading();
  349. });
  350. },
  351. doSearch() {
  352. this.isEnd = false;
  353. this.page = 1;
  354. this.getList();
  355. },
  356. //获取列表信息
  357. getList() {
  358. this.userInfo = uni.getStorageSync("userInfo");
  359. if (this.isEnd || !this.userInfo.userId) {
  360. return;
  361. }
  362. uni.showLoading({
  363. title: "加载中",
  364. });
  365. let data = {
  366. pageNum: this.page,
  367. size: this.size,
  368. keyword: this.keyWord,
  369. areaId: "",
  370. categoryLevelId: this.categoryLevelId || '',
  371. meterReadingMethod: 1,
  372. currentLoginUserId: this.userInfo.userId,
  373. energyClassificationCode: this.energyClassificationCode
  374. };
  375. getList(data)
  376. .then((res) => {
  377. if (this.page === 1) {
  378. this.tableList = res.list;
  379. } else {
  380. this.tableList.push(...res.list);
  381. }
  382. this.page += 1;
  383. this.isEnd = this.tableList.length >= res.count;
  384. })
  385. .then(() => {
  386. uni.hideLoading();
  387. });
  388. },
  389. scrolltolower() {
  390. if (this.isEnd) {
  391. return;
  392. }
  393. this.getList();
  394. },
  395. },
  396. };
  397. </script>
  398. <style lang="scss" scoped>
  399. .mainBox {
  400. background-color: #f3f8fb;
  401. }
  402. .add {
  403. width: 96rpx;
  404. height: 96rpx;
  405. border-radius: 48rpx;
  406. background: #3c9cff;
  407. position: fixed;
  408. bottom: 100rpx;
  409. right: 24rpx;
  410. display: flex;
  411. align-items: center;
  412. justify-content: center;
  413. }
  414. .top-wrapper {
  415. background-color: #fff;
  416. display: flex;
  417. width: 750rpx;
  418. height: 88rpx;
  419. padding: 16rpx 32rpx;
  420. align-items: center;
  421. // gap: 16rpx;
  422. position: absolute;
  423. z-index: 999;
  424. // top: 44px;
  425. // // #ifdef APP-PLUS
  426. // top: 140rpx;
  427. // // #endif
  428. /deep/.uni-section {
  429. margin-top: 0px;
  430. }
  431. /deep/.uni-section-header {
  432. padding: 0px;
  433. }
  434. .search_btn {
  435. width: 120rpx;
  436. height: 70rpx;
  437. line-height: 70rpx;
  438. padding: 0 24rpx;
  439. background: $theme-color;
  440. font-size: 32rpx;
  441. color: #fff;
  442. margin: 0;
  443. margin-left: 26rpx;
  444. }
  445. .menu_icon {
  446. width: 44rpx;
  447. height: 44rpx;
  448. margin-left: 14rpx;
  449. }
  450. }
  451. </style>