equipment-list.vue 14 KB

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