list.vue 19 KB

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