equipment-list.vue 14 KB

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