boat-list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. <template>
  2. <div>
  3. <boat-search
  4. @search="reload"
  5. ref="searchRef"
  6. :networkCounts="networkCounts"
  7. >
  8. </boat-search>
  9. <!-- 数据表格 -->
  10. <ele-pro-table
  11. ref="table"
  12. :pageSizes="tablePageSizes"
  13. :page-size="defPageSize"
  14. :columns="columns"
  15. :datasource="datasource"
  16. height="calc(100vh - 320px)"
  17. full-height="calc(100vh - 115px)"
  18. tool-class="ele-toolbar-form"
  19. cache-key="systemOrgUserTable"
  20. @select="selectChange"
  21. @select-all="changeSelectAll"
  22. >
  23. <!-- 表头工具栏 -->
  24. <template v-slot:toolbar>
  25. <el-button
  26. size="small"
  27. type="primary"
  28. icon="el-icon-plus"
  29. class="ele-btn-icon"
  30. @click="add"
  31. >
  32. 新建
  33. </el-button>
  34. <el-button
  35. size="small"
  36. type="primary"
  37. icon="el-icon-download"
  38. class="ele-btn-icon"
  39. @click="btnExport"
  40. :loading="loading"
  41. >
  42. 导出
  43. </el-button>
  44. <el-button
  45. :disabled="checkRadioData.length == 0"
  46. size="small"
  47. icon="el-icon-set-up"
  48. class="ele-btn-icon"
  49. @click="allPrinting()"
  50. >
  51. 打印条码
  52. </el-button>
  53. <el-button
  54. size="small"
  55. :disabled="checkRadioData.length == 0"
  56. icon="el-icon-thumb"
  57. class="ele-btn-icon"
  58. @click="moveTo(checkRadioData, 'person')"
  59. v-if="$hasPermission('main:substance:update')"
  60. >
  61. 设置片区负责人
  62. </el-button>
  63. <el-button
  64. size="small"
  65. :disabled="checkRadioData.length == 0"
  66. icon="el-icon-s-tools"
  67. class="ele-btn-icon"
  68. @click="batchSettings(1)"
  69. v-if="$hasPermission('main:substance:update')"
  70. >
  71. 设置权属部门
  72. </el-button>
  73. <el-button
  74. size="small"
  75. :disabled="checkRadioData.length == 0"
  76. icon="el-icon-setting"
  77. class="ele-btn-icon"
  78. @click="batchSettings(2)"
  79. v-if="$hasPermission('main:substance:update')"
  80. >
  81. 设置使用单位
  82. </el-button>
  83. <el-button
  84. size="small"
  85. :disabled="checkRadioData.length == 0"
  86. icon="el-icon-s-tools"
  87. class="ele-btn-icon"
  88. type="danger"
  89. @click="setStatus(1)"
  90. v-if="$hasPermission('main:substance:stop')"
  91. >
  92. 批量停机
  93. </el-button>
  94. <el-button
  95. size="small"
  96. :disabled="checkRadioData.length == 0"
  97. icon="el-icon-setting"
  98. class="ele-btn-icon"
  99. @click="setStatus(2)"
  100. v-if="$hasPermission('main:substance:run')"
  101. >
  102. 批量运行
  103. </el-button>
  104. </template>
  105. <!-- 编码列 -->
  106. <template v-slot:code="{ row }">
  107. <el-link @click="details(row)" type="primary" :underline="false">
  108. {{ row.code }}
  109. </el-link>
  110. </template>
  111. <template v-slot:action="{ row }">
  112. <el-link
  113. type="primary"
  114. :underline="false"
  115. icon="el-icon-edit"
  116. @click="handEdit(row)"
  117. >
  118. 编辑
  119. </el-link>
  120. <el-link type="primary" @click="$refs.accountingLedgerListRef.open(row)"
  121. >表计BOM</el-link
  122. >
  123. </template>
  124. </ele-pro-table>
  125. <print ref="printRef"></print>
  126. <printSr ref="printSrRef"></printSr>
  127. <printTg ref="printTgRef"></printTg>
  128. <batchSetDialog ref="batchSetRef" @success="sucesstion" />
  129. <DialogMoveto ref="movetoRef" @success="sucesstion" />
  130. <accountingLedgerList ref="accountingLedgerListRef"></accountingLedgerList>
  131. </div>
  132. </template>
  133. <script>
  134. import accountingLedgerList from '@/views/ledgerAssets/components/accountingLedgerList.vue';
  135. import print from '@/views/ledgerAssets/components/print.vue';
  136. import printSr from '@/views/ledgerAssets/components/printSr';
  137. import printTg from '@/views/ledgerAssets/components/printTg';
  138. import batchSetDialog from '@/views/ledgerAssets/equipment/components/batchSetDialog.vue';
  139. import DialogMoveto from '@/views/ledgerAssets/equipment/components/DialogMoveTo.vue';
  140. import { getByCode } from '@/api/system/dictionary-data';
  141. import {
  142. businessStatus,
  143. networkStatus,
  144. sourceStatus
  145. } from '@/utils/dict/warehouse';
  146. import BoatSearch from '@/views/ledgerAssets/equipment/components/equipment-search.vue';
  147. import {
  148. getBoatList,
  149. downloadCategory,
  150. getAssetList,
  151. batchStop,
  152. batchRun
  153. } from '@/api/ledgerAssets';
  154. // import { downloadAction } from '@/api/flowable/manage';
  155. import dictMixins from '@/mixins/dictMixins';
  156. import axios from 'axios';
  157. import {
  158. API_BASE_URL,
  159. TOKEN_HEADER_NAME,
  160. LAYOUT_PATH
  161. } from '@/config/setting';
  162. import { download } from '@/utils/file';
  163. import { getToken, setToken } from '@/utils/token-util';
  164. export default {
  165. mixins: [dictMixins],
  166. components: {
  167. BoatSearch,
  168. print,
  169. printSr,
  170. printTg,
  171. DialogMoveto,
  172. batchSetDialog,
  173. accountingLedgerList
  174. },
  175. props: {
  176. // 类别id
  177. categoryId: [Number, String],
  178. rootId: [Number, String]
  179. },
  180. data() {
  181. return {
  182. QRvisible: false,
  183. checkRadioData: [],
  184. businessStatus,
  185. networkStatus,
  186. assetLevel: [],
  187. networkCounts: {},
  188. isConsumer: false,
  189. // 表格列配置
  190. columns: [
  191. {
  192. width: 45,
  193. type: 'selection',
  194. columnKey: 'selection',
  195. align: 'center'
  196. },
  197. {
  198. columnKey: 'index',
  199. type: 'index',
  200. label: '序号',
  201. width: 55,
  202. align: 'center',
  203. showOverflowTooltip: true,
  204. fixed: 'left'
  205. },
  206. {
  207. columnKey: 'code',
  208. prop: 'code',
  209. slot: 'code',
  210. label: '编码',
  211. showOverflowTooltip: true,
  212. minWidth: 200
  213. },
  214. {
  215. prop: 'category.name',
  216. label: '名称',
  217. showOverflowTooltip: true,
  218. minWidth: 110
  219. },
  220. {
  221. prop: 'fixCode',
  222. label: '固资编码',
  223. showOverflowTooltip: true,
  224. minWidth: 110
  225. },
  226. {
  227. prop: 'codeNumber',
  228. label: '编号',
  229. showOverflowTooltip: true,
  230. minWidth: 110
  231. },
  232. {
  233. prop: 'category.modelType',
  234. label: '型号',
  235. showOverflowTooltip: true,
  236. minWidth: 110
  237. },
  238. {
  239. prop: 'category.specification',
  240. label: '规格',
  241. showOverflowTooltip: true,
  242. minWidth: 110
  243. },
  244. {
  245. prop: 'manufacturer',
  246. label: '制造厂',
  247. showOverflowTooltip: true,
  248. minWidth: 110
  249. },
  250. {
  251. prop: 'manufactureTime',
  252. label: '制造日期',
  253. showOverflowTooltip: true,
  254. minWidth: 110
  255. },
  256. {
  257. prop: 'createAccountsTime',
  258. label: '建账日期',
  259. showOverflowTooltip: true,
  260. minWidth: 110
  261. },
  262. {
  263. prop: 'postName',
  264. label: '使用单位',
  265. showOverflowTooltip: true,
  266. minWidth: 110
  267. },
  268. {
  269. prop: 'usePerson',
  270. label: '使用人',
  271. showOverflowTooltip: true,
  272. minWidth: 80
  273. },
  274. {
  275. prop: 'ownershipGroupName',
  276. label: '权属部门',
  277. showOverflowTooltip: true,
  278. minWidth: 110
  279. },
  280. {
  281. prop: 'areaPersonInChargeUserName',
  282. label: '片区负责人',
  283. showOverflowTooltip: true,
  284. minWidth: 150
  285. },
  286. {
  287. prop: 'repairUserName',
  288. label: '维修人',
  289. showOverflowTooltip: true,
  290. minWidth: 150
  291. },
  292. {
  293. prop: 'endTime',
  294. label: '有效期结束时间',
  295. showOverflowTooltip: true,
  296. minWidth: 150
  297. },
  298. {
  299. prop: 'source',
  300. label: '生命周期',
  301. showOverflowTooltip: true,
  302. minWidth: 110,
  303. formatter: (_row) => {
  304. return sourceStatus[_row.lifeCycle];
  305. }
  306. },
  307. {
  308. prop: 'level',
  309. label: '级别',
  310. showOverflowTooltip: true,
  311. minWidth: 110,
  312. formatter: (_row) => {
  313. if (_row.level) {
  314. return this.assetLevel.filter(
  315. (item) => item.id == _row.level
  316. )[0].name;
  317. } else {
  318. return '';
  319. }
  320. }
  321. },
  322. {
  323. prop: 'networkStatus',
  324. label: '网络状态',
  325. showOverflowTooltip: true,
  326. minWidth: 110,
  327. formatter: (_row) => {
  328. if (_row.networkStatus) {
  329. return this.networkStatus.filter(
  330. (item) => item.code == _row.networkStatus
  331. )[0].label;
  332. } else {
  333. return '离线';
  334. }
  335. }
  336. },
  337. {
  338. prop: 'status',
  339. label: '状态',
  340. showOverflowTooltip: true,
  341. minWidth: 110,
  342. formatter: (_row) => {
  343. if (_row.status) {
  344. return this.businessStatus.filter(
  345. (item) => item.code == _row.status
  346. )[0].label;
  347. } else {
  348. return '空闲';
  349. }
  350. }
  351. },
  352. {
  353. prop: 'runStatus',
  354. label: '运行状态',
  355. showOverflowTooltip: true,
  356. minWidth: 110,
  357. formatter: (_row) => {
  358. return _row.runStatus == 5 ? '停机' : '运行';
  359. }
  360. },
  361. {
  362. prop: 'pathName',
  363. label: '位置',
  364. showOverflowTooltip: true,
  365. minWidth: 110,
  366. formatter: (_row) => {
  367. const positionDetail =
  368. _row.position &&
  369. _row.position.length != 0 &&
  370. _row.position[0].detailPosition
  371. ? _row.position[0].detailPosition
  372. : '-';
  373. return _row.deviceLocationName
  374. ? _row.deviceLocationName + '-' + positionDetail
  375. : '';
  376. }
  377. },
  378. {
  379. columnKey: 'action',
  380. slot: 'action',
  381. label: '操作',
  382. minWidth: 150,
  383. fixed: 'right'
  384. }
  385. ],
  386. loading: false
  387. };
  388. },
  389. computed: {
  390. clientEnvironmentId() {
  391. return this.$store.state.user.info.clientEnvironmentId;
  392. }
  393. },
  394. created() {
  395. this.requestDict('角度');
  396. this.getAssetLevelOptions();
  397. },
  398. methods: {
  399. // 刷新回调
  400. sucesstion(is) {
  401. console.log(is);
  402. if (is) {
  403. this.reload();
  404. }
  405. this.checkRadioData = [];
  406. },
  407. // 移动到
  408. moveTo(arr, type) {
  409. this.$refs.movetoRef.open(arr, this.current, type);
  410. },
  411. batchSettings(type) {
  412. let ids = this.checkRadioData.map((item) => {
  413. return item.id;
  414. });
  415. this.$refs.batchSetRef.open(type, ids);
  416. console.log(this.checkRadioData, 'checkRadioData 123');
  417. },
  418. allPrinting() {
  419. if (this.clientEnvironmentId == 2) {
  420. this.$refs.printSrRef.open(this.checkRadioData);
  421. } else if (this.clientEnvironmentId == 3) {
  422. this.$refs.printTgRef.open(this.checkRadioData);
  423. } else {
  424. this.$refs.printRef.open(this.checkRadioData);
  425. }
  426. },
  427. // 全选
  428. changeSelectAll(arr) {
  429. console.log(arr);
  430. if (arr.length != 0) {
  431. this.checkRadioData = arr;
  432. } else {
  433. this.checkRadioData = [];
  434. }
  435. },
  436. selectChange(selection, row) {
  437. if (selection.length != 0) {
  438. this.checkRadioData = selection;
  439. } else {
  440. this.checkRadioData = [];
  441. }
  442. },
  443. setStatus(type) {
  444. let api = type == 1 ? batchStop : batchRun;
  445. api(this.checkRadioData.map((item) => item.id)).then((res) => {
  446. this.$message.success('操作成功');
  447. this.sucesstion(true);
  448. });
  449. },
  450. add() {
  451. this.$router.push({
  452. path: '/ledgerAssets/boat/edit'
  453. });
  454. },
  455. // 获取资产级别下拉
  456. async getAssetLevelOptions() {
  457. let { data } = await getByCode('asset_level');
  458. this.assetLevel =
  459. data.length > 0
  460. ? data.map((item) => {
  461. return {
  462. name: Object.keys(item)[0],
  463. id: item[Object.keys(item)[0]]
  464. };
  465. })
  466. : [];
  467. },
  468. /* 跳转到编辑 */
  469. handEdit({ id }) {
  470. this.$router.push({
  471. path: '/ledgerAssets/boat/edit',
  472. query: {
  473. id
  474. }
  475. });
  476. },
  477. /* 表格数据源 */
  478. datasource({ page, limit, where, order }) {
  479. return getAssetList({
  480. ...where,
  481. ...order,
  482. pageNum: page,
  483. size: limit,
  484. categoryLevelId: this.categoryId,
  485. rootCategoryLevelId: this.rootId
  486. });
  487. },
  488. /* 刷新表格 */
  489. reload(where) {
  490. this.$refs.table.reload({ pageNum: 1, where: where });
  491. },
  492. // 跳转到详情页
  493. details({ id, code }) {
  494. this.$router.push({
  495. path: '/ledgerAssets/boat/detail',
  496. query: {
  497. id,
  498. code
  499. }
  500. });
  501. },
  502. // 导出
  503. btnExport() {
  504. let params = {
  505. ...this.$refs.searchRef.where,
  506. exportType: 1,
  507. categoryLevelId: this.categoryId,
  508. rootCategoryLevelId: this.rootId
  509. };
  510. this.loading = true;
  511. // downloadCategory(params, '舟皿台账导出数据');
  512. axios({
  513. url: `${API_BASE_URL}/main/asset/page/export`,
  514. method: 'post',
  515. responseType: 'blob',
  516. headers: {
  517. Authorization: getToken()
  518. },
  519. data: params
  520. })
  521. .then((res) => {
  522. this.loading = false;
  523. download(res.data, '舟皿台账导出数据');
  524. this.$message.success('操作成功');
  525. })
  526. .catch((err) => {
  527. this.loading = false;
  528. });
  529. }
  530. },
  531. watch: {
  532. // 监听类别id变化
  533. categoryId() {
  534. this.reload();
  535. }
  536. }
  537. };
  538. </script>