boat-list.vue 13 KB

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