equipment-list.vue 13 KB

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