turnovercar-list.vue 14 KB

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