equipment-list.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  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. :initLoad="false"
  19. @select="selectChange"
  20. @select-all="changeSelectAll"
  21. >
  22. <!-- 表头工具栏 -->
  23. <template v-slot:toolbar="{ row }" v-if="!$route.query.isDrawer">
  24. <el-button
  25. size="small"
  26. type="primary"
  27. icon="el-icon-plus"
  28. class="ele-btn-icon"
  29. @click="add"
  30. v-if="$hasPermission('main:substance:save')"
  31. >
  32. 新建
  33. </el-button>
  34. <el-button
  35. size="small"
  36. icon="el-icon-download"
  37. class="ele-btn-icon"
  38. type="primary"
  39. @click="exportFile"
  40. v-if="$hasPermission('main:exportFile:save')"
  41. >
  42. 导出
  43. </el-button>
  44. <el-button
  45. size="small"
  46. :disabled="checkRadioData.length == 0"
  47. icon="el-icon-set-up"
  48. class="ele-btn-icon"
  49. @click="allPrinting()"
  50. >
  51. 打印条码
  52. </el-button>
  53. <el-button
  54. size="small"
  55. :disabled="checkRadioData.length == 0"
  56. icon="el-icon-thumb"
  57. class="ele-btn-icon"
  58. @click="moveTo(checkRadioData, 'person')"
  59. v-if="$hasPermission('main:substance:update')"
  60. >
  61. 设置片区负责人
  62. </el-button>
  63. <el-button
  64. size="small"
  65. :disabled="checkRadioData.length == 0"
  66. icon="el-icon-s-tools"
  67. class="ele-btn-icon"
  68. @click="batchSettings(1)"
  69. v-if="$hasPermission('main:substance:update')"
  70. >
  71. 设置权属部门
  72. </el-button>
  73. <el-button
  74. size="small"
  75. :disabled="checkRadioData.length == 0"
  76. icon="el-icon-setting"
  77. class="ele-btn-icon"
  78. @click="batchSettings(2)"
  79. v-if="$hasPermission('main:substance:update')"
  80. >
  81. 设置使用单位
  82. </el-button>
  83. <el-button
  84. size="small"
  85. type="danger"
  86. icon="el-icon-delete"
  87. class="ele-btn-icon"
  88. @click="handlDelete"
  89. v-if="$hasPermission('main:substance:delete')"
  90. >批量删除</el-button
  91. >
  92. <el-button
  93. type="primary"
  94. size="small"
  95. icon="el-icon-upload2"
  96. @click="uploadFile"
  97. >导入</el-button
  98. >
  99. <!-- <el-button
  100. size="small"
  101. @click="moveTo(checkRadioData, 'move')"
  102. :disabled="checkRadioData.length == 0"
  103. class="ele-btn-icon"
  104. >移动到</el-button
  105. > -->
  106. </template>
  107. <!-- 编码列 -->
  108. <template v-slot:code="{ row }" v-if="!$route.query.isDrawer">
  109. <el-link type="primary" :underline="false" @click="details(row)">
  110. {{ row.code }}
  111. </el-link>
  112. </template>
  113. <!-- 操作列 -->
  114. <template v-slot:action="{ row }" v-if="!$route.query.isDrawer">
  115. <el-popconfirm
  116. class="ele-action"
  117. title="确定要删除此设备数据吗?"
  118. @confirm="handleRemove(row)"
  119. v-if="$hasPermission('main:substance:delete')"
  120. >
  121. <template v-slot:reference>
  122. <el-link type="danger" :underline="false" icon="el-icon-delete"
  123. >删除</el-link
  124. >
  125. </template>
  126. </el-popconfirm>
  127. <el-link
  128. type="primary"
  129. :underline="false"
  130. icon="el-icon-edit"
  131. @click="handEdit(row)"
  132. v-if="$hasPermission('main:substance:update')"
  133. >
  134. 编辑
  135. </el-link>
  136. <el-link type="primary" @click="handelBOM(row)">BOM</el-link>
  137. <el-link type="primary" @click="$refs.accountingLedgerListRef.open(row)"
  138. >表计BOM</el-link
  139. >
  140. </template>
  141. </ele-pro-table>
  142. <print ref="printRef"></print>
  143. <printSr ref="printSrRef"></printSr>
  144. <printTg ref="printTgRef"></printTg>
  145. <BomDetailsPop ref="bomDrawer"></BomDetailsPop>
  146. <batchSetDialog ref="batchSetRef" @success="sucesstion" />
  147. <DialogMoveto ref="movetoRef" @success="sucesstion" />
  148. <importDialog
  149. ref="importDialogRef"
  150. @success="reload"
  151. :fileUrl="'/main/asset/importTemplate'"
  152. :isWeb="false"
  153. fileName="设备台账导入模板"
  154. apiUrl="/main/asset/importFile"
  155. :rootCategoryLevelId="rootId"
  156. />
  157. <accountingLedgerList ref="accountingLedgerListRef"></accountingLedgerList>
  158. </div>
  159. </template>
  160. <script>
  161. import batchSetDialog from './batchSetDialog.vue';
  162. import DialogMoveto from './DialogMoveTo.vue';
  163. import print from '@/views/ledgerAssets/components/print.vue';
  164. import accountingLedgerList from '@/views/ledgerAssets/components/accountingLedgerList.vue';
  165. import printSr from '@/views/ledgerAssets/components/printSr';
  166. import printTg from '@/views/ledgerAssets/components/printTg';
  167. import { getByCode } from '@/api/system/dictionary-data';
  168. import importDialog from '@/components/upload/import-dialog.vue';
  169. import {
  170. businessStatus,
  171. networkStatus,
  172. sourceStatus
  173. } from '@/utils/dict/warehouse';
  174. import EquipmentSearch from './equipment-search.vue';
  175. import {
  176. getAssetList,
  177. downloadAsset,
  178. getNetworkCount,
  179. batchDel
  180. } from '@/api/ledgerAssets';
  181. import dictMixins from '@/mixins/dictMixins';
  182. import axios from 'axios';
  183. import {
  184. API_BASE_URL,
  185. TOKEN_HEADER_NAME,
  186. LAYOUT_PATH
  187. } from '@/config/setting';
  188. import { download } from '@/utils/file';
  189. import { getToken, setToken } from '@/utils/token-util';
  190. import BomDetailsPop from '@/views/ledgerAssets/equipment/detailsPop.vue';
  191. export default {
  192. components: {
  193. EquipmentSearch,
  194. print,
  195. printSr,
  196. printTg,
  197. BomDetailsPop,
  198. importDialog,
  199. DialogMoveto,
  200. batchSetDialog,
  201. accountingLedgerList
  202. },
  203. mixins: [dictMixins],
  204. props: {
  205. // 类别id
  206. categoryId: [Number, String],
  207. rootId: [Number, String],
  208. current: {
  209. typeof: Object,
  210. default: {}
  211. }
  212. },
  213. data() {
  214. return {
  215. businessStatus,
  216. networkStatus,
  217. assetLevel: [],
  218. isConsumer: false,
  219. currentPage: 1,
  220. // 表格列配置
  221. columns: [
  222. {
  223. width: 45,
  224. type: 'selection',
  225. columnKey: 'selection',
  226. align: 'center'
  227. },
  228. {
  229. columnKey: 'index',
  230. type: 'index',
  231. label: '序号',
  232. width: 55,
  233. align: 'center',
  234. showOverflowTooltip: true,
  235. fixed: 'left'
  236. },
  237. {
  238. columnKey: 'code',
  239. prop: 'code',
  240. slot: 'code',
  241. label: '编码',
  242. showOverflowTooltip: true,
  243. minWidth: 180
  244. },
  245. // {
  246. // columnKey: 'code',
  247. // prop: 'code',
  248. // label: '设备编码',
  249. // showOverflowTooltip: true,
  250. // minWidth: 110,
  251. // slot: 'code'
  252. // },
  253. {
  254. prop: 'category.name',
  255. label: '名称',
  256. showOverflowTooltip: true,
  257. minWidth: 110
  258. },
  259. {
  260. prop: 'fixCode',
  261. label: '固资编码',
  262. showOverflowTooltip: true,
  263. minWidth: 110
  264. },
  265. {
  266. prop: 'codeNumber',
  267. label: '编号',
  268. showOverflowTooltip: true,
  269. minWidth: 110
  270. },
  271. // {
  272. // prop: 'codeNumber',
  273. // label: '编号',
  274. // showOverflowTooltip: true,
  275. // minWidth: 110
  276. // },
  277. {
  278. prop: 'category.modelType',
  279. label: '型号',
  280. showOverflowTooltip: true,
  281. minWidth: 110
  282. },
  283. {
  284. prop: 'category.specification',
  285. label: '规格',
  286. showOverflowTooltip: true,
  287. minWidth: 110
  288. },
  289. {
  290. prop: 'workstationInfo.name',
  291. label: '工位名称',
  292. showOverflowTooltip: true,
  293. minWidth: 110
  294. },
  295. {
  296. prop: 'manufacturer',
  297. label: '制造厂',
  298. showOverflowTooltip: true,
  299. minWidth: 110
  300. },
  301. {
  302. prop: 'manufactureTime',
  303. label: '制造日期',
  304. showOverflowTooltip: true,
  305. minWidth: 110
  306. },
  307. {
  308. prop: 'createAccountsTime',
  309. label: '建账日期',
  310. showOverflowTooltip: true,
  311. minWidth: 110
  312. },
  313. {
  314. prop: 'postName',
  315. label: '使用单位',
  316. showOverflowTooltip: true,
  317. minWidth: 110
  318. },
  319. {
  320. prop: 'usePerson',
  321. label: '使用人',
  322. showOverflowTooltip: true,
  323. minWidth: 80
  324. },
  325. {
  326. prop: 'ownershipGroupName',
  327. label: '权属部门',
  328. showOverflowTooltip: true,
  329. minWidth: 110
  330. },
  331. {
  332. prop: 'areaPersonInChargeUserName',
  333. label: '片区负责人',
  334. showOverflowTooltip: true,
  335. minWidth: 150
  336. },
  337. {
  338. prop: 'repairUserName',
  339. label: '维修人',
  340. showOverflowTooltip: true,
  341. minWidth: 150
  342. },
  343. {
  344. prop: 'endTime',
  345. label: '有效期结束时间',
  346. showOverflowTooltip: true,
  347. minWidth: 150
  348. },
  349. {
  350. prop: 'source',
  351. label: '生命周期',
  352. showOverflowTooltip: true,
  353. minWidth: 110,
  354. formatter: (_row) => {
  355. return sourceStatus[_row.lifeCycle];
  356. }
  357. },
  358. {
  359. prop: 'level',
  360. label: '级别',
  361. showOverflowTooltip: true,
  362. minWidth: 110,
  363. formatter: (_row) => {
  364. if (_row.level) {
  365. return this.assetLevel.filter(
  366. (item) => item.id == _row.level
  367. )[0]?.name;
  368. } else {
  369. return '';
  370. }
  371. }
  372. },
  373. {
  374. prop: 'networkStatus',
  375. label: '网络状态',
  376. showOverflowTooltip: true,
  377. minWidth: 110,
  378. formatter: (_row) => {
  379. if (_row.networkStatus) {
  380. return this.networkStatus.filter(
  381. (item) => item.code == _row.networkStatus
  382. )[0].label;
  383. } else {
  384. return '离线';
  385. }
  386. }
  387. },
  388. {
  389. prop: 'status',
  390. label: '状态',
  391. showOverflowTooltip: true,
  392. minWidth: 110,
  393. formatter: (_row) => {
  394. if (_row.status) {
  395. return this.businessStatus.filter(
  396. (item) => item.code == _row.status
  397. )[0].label;
  398. } else {
  399. return '空闲';
  400. }
  401. }
  402. },
  403. {
  404. prop: 'pathName',
  405. label: '位置',
  406. showOverflowTooltip: true,
  407. minWidth: 110,
  408. formatter: (_row) => {
  409. const positionDetail =
  410. _row.position &&
  411. _row.position.length != 0 &&
  412. _row.position[0].detailPosition
  413. ? _row.position[0].detailPosition
  414. : '-';
  415. return _row.deviceLocationName
  416. ? _row.deviceLocationName + '-' + positionDetail
  417. : '';
  418. }
  419. },
  420. {
  421. columnKey: 'action',
  422. slot: 'action',
  423. label: '操作',
  424. minWidth: 320,
  425. align: 'center',
  426. fixed: 'right'
  427. }
  428. ],
  429. networkCounts: {},
  430. checkRadioData: [],
  431. QRvisible: false
  432. };
  433. },
  434. computed: {
  435. clientEnvironmentId() {
  436. console.log('this.$store.state.user.---computed---');
  437. console.log(this.$store.state.user);
  438. return this.$store.state.user.info.clientEnvironmentId;
  439. }
  440. },
  441. created() {
  442. console.log('this.$store.state.user.-------------------');
  443. console.log(this.$store.state.user);
  444. this.requestDict('网络状态');
  445. this.getAssetLevelOptions();
  446. },
  447. methods: {
  448. //导入
  449. uploadFile() {
  450. this.$refs.importDialogRef.open();
  451. },
  452. allPrinting() {
  453. console.log('this.clientEnvironmentId-------------');
  454. console.log(this.clientEnvironmentId);
  455. if (this.clientEnvironmentId == 2) {
  456. this.$refs.printSrRef.open(this.checkRadioData);
  457. } else if (this.clientEnvironmentId == 3) {
  458. this.$refs.printTgRef.open(this.checkRadioData);
  459. } else {
  460. this.$refs.printRef.open(this.checkRadioData);
  461. }
  462. },
  463. // 获取资产级别下拉
  464. async getAssetLevelOptions() {
  465. let { data } = await getByCode('asset_level');
  466. this.assetLevel =
  467. data.length > 0
  468. ? data.map((item) => {
  469. return {
  470. name: Object.keys(item)[0],
  471. id: item[Object.keys(item)[0]]
  472. };
  473. })
  474. : [];
  475. },
  476. // 刷新回调
  477. sucesstion(is) {
  478. console.log(is);
  479. if (is) {
  480. this.reload();
  481. }
  482. this.checkRadioData = [];
  483. },
  484. // 移动到
  485. moveTo(arr, type) {
  486. this.$refs.movetoRef.open(arr, this.current, type);
  487. },
  488. // 全选
  489. changeSelectAll(arr) {
  490. console.log(arr);
  491. if (arr.length != 0) {
  492. this.checkRadioData = arr;
  493. } else {
  494. this.checkRadioData = [];
  495. }
  496. },
  497. selectChange(selection, row) {
  498. if (selection.length != 0) {
  499. this.checkRadioData = selection;
  500. } else {
  501. this.checkRadioData = [];
  502. }
  503. },
  504. handlDelete() {
  505. if (this.checkRadioData.length == 0) {
  506. this.$message.warning('请至少选择一条数据');
  507. return;
  508. }
  509. if (this.checkRadioData.length != 0) {
  510. this.$confirm('是否删除?', '提示', {
  511. confirmButtonText: '确定',
  512. cancelButtonText: '取消',
  513. type: 'warning'
  514. })
  515. .then(async () => {
  516. const paramsArr = this.checkRadioData.map((item) => {
  517. return item.id;
  518. });
  519. await batchDel(paramsArr);
  520. this.$message.success('操作成功');
  521. this.sucesstion(true);
  522. })
  523. .catch(() => {});
  524. }
  525. },
  526. async handleRemove(row) {
  527. let arr = [row.id];
  528. const res = await batchDel(arr);
  529. if (res) {
  530. this.$message.success('操作成功');
  531. this.sucesstion(true);
  532. }
  533. },
  534. /* 表格数据源 */
  535. datasource({ page, limit, where, order }) {
  536. console.log('------reload-------');
  537. this.currentPage = page;
  538. return getAssetList({
  539. ...order,
  540. pageNum: page,
  541. size: limit,
  542. ...where,
  543. categoryLevelId: this.categoryId,
  544. rootCategoryLevelId: this.rootId
  545. });
  546. },
  547. async getNetWork(page, limit, where, order) {
  548. const res = await getNetworkCount({
  549. ...where,
  550. ...order,
  551. pageNum: page,
  552. size: limit,
  553. categoryLevelId: this.categoryId,
  554. rootCategoryLevelId: this.rootId
  555. });
  556. this.networkCounts = res;
  557. console.log(res, 'resresresresresresresresresresresresresres');
  558. },
  559. /* 刷新表格 */
  560. reload(where) {
  561. this.$refs.table.reload({ pageNum: 1, where: where });
  562. },
  563. // /* 刷新表格 */
  564. // reloadNew() {
  565. // this.$refs.table.reload({
  566. // ...this.$refs.search.where,
  567. // pageNum: this.currentPage
  568. // });
  569. // },
  570. // 跳转到详情页
  571. details({ id, code, name }) {
  572. this.$router.push({
  573. path: '/ledgerAssets/equipment/detail',
  574. query: {
  575. id,
  576. code,
  577. name
  578. }
  579. });
  580. },
  581. // 跳转到编辑
  582. handEdit({ id }) {
  583. this.$router.push({
  584. path: '/ledgerAssets/equipment/edit',
  585. query: {
  586. id
  587. }
  588. });
  589. },
  590. // 跳转到详情页
  591. add() {
  592. this.$router.push({
  593. path: '/ledgerAssets/equipment/edit'
  594. });
  595. },
  596. exportFile() {
  597. let params = {
  598. ...this.$refs.search.where,
  599. exportType: 1,
  600. categoryLevelId: this.categoryId,
  601. rootCategoryLevelId: this.rootId
  602. };
  603. // downloadAsset(params, '设备台账导出数据');
  604. axios({
  605. url: `${API_BASE_URL}/main/asset/page/export`,
  606. method: 'post',
  607. responseType: 'blob',
  608. headers: {
  609. Authorization: getToken()
  610. },
  611. data: params
  612. }).then((res) => {
  613. download(res.data, '设备台账导出数据');
  614. });
  615. },
  616. handelBOM(row) {
  617. let rowData = {
  618. categoryId: row.category.id,
  619. categoryName: row.categoryName,
  620. code: row.code,
  621. versions: row.versions,
  622. rootPathIdParent: row.category.categoryLevelPathIdParent,
  623. isProduct: true,
  624. bomType: '1',
  625. isTemp: row.isTemp,
  626. substanceId: row.id
  627. };
  628. this.$refs.bomDrawer.open(rowData);
  629. },
  630. batchSettings(type) {
  631. let ids = this.checkRadioData.map((item) => {
  632. return item.id;
  633. });
  634. this.$refs.batchSetRef.open(type, ids);
  635. console.log(this.checkRadioData, 'checkRadioData 123');
  636. }
  637. },
  638. watch: {
  639. // 监听类别id变化
  640. categoryId() {
  641. this.reload();
  642. }
  643. }
  644. };
  645. </script>
  646. <style lang="scss" scoped>
  647. @media print {
  648. #printSection {
  649. font-size: 34px;
  650. span {
  651. font-size: 34px;
  652. }
  653. }
  654. }
  655. </style>