equipment-list.vue 12 KB

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