data-list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <template>
  2. <div>
  3. <user-search
  4. ref="searchRef"
  5. @search="reload"
  6. :networkCounts="networkCounts"
  7. >
  8. </user-search>
  9. <!-- 数据表格 -->
  10. <ele-pro-table
  11. ref="table"
  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>
  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. type="primary"
  35. icon="el-icon-download"
  36. class="ele-btn-icon"
  37. @click="btnExport"
  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="details(row)">
  84. {{ row.code }}
  85. </el-link>
  86. </template>
  87. <!-- 牌号列 -->
  88. <template v-slot:brandNum="{ row }">
  89. <div>
  90. {{ row.category.brandNum }}
  91. </div>
  92. </template>
  93. <!-- 型号列 -->
  94. <template v-slot:modelType="{ row }">
  95. <div>
  96. {{ row.category.modelType }}
  97. </div>
  98. </template>
  99. <!-- 分类列 -->
  100. <template v-slot:categoryLevelPath="{ row }">
  101. <div>
  102. {{ row.category.categoryLevelPath }}
  103. </div>
  104. </template>
  105. <!-- 操作列 -->
  106. <template v-slot:action="{ row }">
  107. <el-link
  108. type="primary"
  109. :underline="false"
  110. icon="el-icon-edit"
  111. @click="goEdit(row)"
  112. >
  113. 编辑
  114. </el-link>
  115. </template>
  116. </ele-pro-table>
  117. <print ref="printRef"></print>
  118. <printSr ref="printSrRef"></printSr>
  119. <printTg ref="printTgRef"></printTg>
  120. <batchSetDialog ref="batchSetRef" @success="sucesstion" />
  121. <DialogMoveto ref="movetoRef" @success="sucesstion" />
  122. </div>
  123. </template>
  124. <script>
  125. import batchSetDialog from '@/views/ledgerAssets/equipment/components/batchSetDialog.vue';
  126. import DialogMoveto from '@/views/ledgerAssets/equipment/components/DialogMoveTo.vue';
  127. import print from '@/views/ledgerAssets/components/print.vue';
  128. import printSr from '@/views/ledgerAssets/components/printSr';
  129. import printTg from '@/views/ledgerAssets/components/printTg';
  130. import { getByCode } from '@/api/system/dictionary-data';
  131. import {
  132. businessStatus,
  133. networkStatus,
  134. sourceStatus
  135. } from '@/utils/dict/warehouse';
  136. import UserSearch from './user-search.vue';
  137. import { getAssetList, downloadAsset } from '@/api/ledgerAssets';
  138. import dictMixins from '@/mixins/dictMixins';
  139. import axios from 'axios';
  140. import {
  141. API_BASE_URL,
  142. TOKEN_HEADER_NAME,
  143. LAYOUT_PATH
  144. } from '@/config/setting';
  145. import { download } from '@/utils/file';
  146. import { getToken, setToken } from '@/utils/token-util';
  147. export default {
  148. components: {
  149. UserSearch,
  150. print,
  151. printSr,
  152. printTg,
  153. DialogMoveto,
  154. batchSetDialog
  155. },
  156. mixins: [dictMixins],
  157. props: {
  158. // 类别id
  159. categoryId: [Number, String],
  160. rootId: [Number, String]
  161. },
  162. data() {
  163. return {
  164. checkRadioData: [],
  165. QRvisible: false,
  166. networkStatus,
  167. businessStatus,
  168. assetLevel: [],
  169. isConsumer: false,
  170. networkCounts: {},
  171. // 表格列配置
  172. columns: [
  173. {
  174. width: 45,
  175. type: 'selection',
  176. columnKey: 'selection',
  177. align: 'center'
  178. },
  179. {
  180. columnKey: 'index',
  181. type: 'index',
  182. label: '序号',
  183. width: 55,
  184. align: 'center',
  185. showOverflowTooltip: true,
  186. fixed: 'left'
  187. },
  188. {
  189. columnKey: 'code',
  190. prop: 'code',
  191. slot: 'code',
  192. label: '编码',
  193. showOverflowTooltip: true,
  194. minWidth: 180
  195. },
  196. // {
  197. // columnKey: 'code',
  198. // prop: 'code',
  199. // label: '设备编码',
  200. // showOverflowTooltip: true,
  201. // minWidth: 110,
  202. // slot: 'code'
  203. // },
  204. {
  205. prop: 'category.name',
  206. label: '名称',
  207. showOverflowTooltip: true,
  208. minWidth: 110
  209. },
  210. {
  211. prop: 'fixCode',
  212. label: '固资编码',
  213. showOverflowTooltip: true,
  214. minWidth: 110
  215. },
  216. {
  217. prop: 'codeNumber',
  218. label: '编号',
  219. showOverflowTooltip: true,
  220. minWidth: 110
  221. },
  222. // {
  223. // prop: 'codeNumber',
  224. // label: '编号',
  225. // showOverflowTooltip: true,
  226. // minWidth: 110
  227. // },
  228. {
  229. prop: 'category.modelType',
  230. label: '型号',
  231. showOverflowTooltip: true,
  232. minWidth: 110
  233. },
  234. {
  235. prop: 'category.specification',
  236. label: '规格',
  237. showOverflowTooltip: true,
  238. minWidth: 110
  239. },
  240. {
  241. prop: 'postName',
  242. label: '使用单位',
  243. showOverflowTooltip: true,
  244. minWidth: 110
  245. },
  246. {
  247. prop: 'usePerson',
  248. label: '使用人',
  249. showOverflowTooltip: true,
  250. minWidth: 80
  251. },
  252. {
  253. prop: 'ownershipGroupName',
  254. label: '权属部门',
  255. showOverflowTooltip: true,
  256. minWidth: 110
  257. },
  258. {
  259. prop: 'chargePerson',
  260. label: '负责人',
  261. showOverflowTooltip: true,
  262. minWidth: 80
  263. },
  264. {
  265. prop: 'endTime',
  266. label: '有效期结束时间',
  267. showOverflowTooltip: true,
  268. minWidth: 150
  269. },
  270. {
  271. prop: 'source',
  272. label: '生命周期',
  273. showOverflowTooltip: true,
  274. minWidth: 110,
  275. formatter: (_row) => {
  276. return sourceStatus[_row.lifeCycle];
  277. }
  278. },
  279. {
  280. prop: 'level',
  281. label: '级别',
  282. showOverflowTooltip: true,
  283. minWidth: 110,
  284. formatter: (_row) => {
  285. if (_row.level) {
  286. return this.assetLevel.filter(
  287. (item) => item.id == _row.level
  288. )[0].name;
  289. } else {
  290. return '';
  291. }
  292. }
  293. },
  294. {
  295. prop: 'networkStatus',
  296. label: '网络状态',
  297. showOverflowTooltip: true,
  298. minWidth: 110,
  299. formatter: (_row) => {
  300. console.log('_row.networkStatus-------', _row.networkStatus);
  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: 100,
  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. allPrinting() {
  363. if (this.clientEnvironmentId == 2) {
  364. this.$refs.printSrRef.open(this.checkRadioData);
  365. } else if (this.clientEnvironmentId == 3) {
  366. this.$refs.printTgRef.open(this.checkRadioData);
  367. } else {
  368. this.$refs.printRef.open(this.checkRadioData);
  369. }
  370. },
  371. // 全选
  372. changeSelectAll(arr) {
  373. console.log(arr);
  374. if (arr.length != 0) {
  375. this.checkRadioData = arr;
  376. } else {
  377. this.checkRadioData = [];
  378. }
  379. },
  380. selectChange(selection, row) {
  381. if (selection.length != 0) {
  382. this.checkRadioData = selection;
  383. } else {
  384. this.checkRadioData = [];
  385. }
  386. },
  387. // 获取资产级别下拉
  388. async getAssetLevelOptions() {
  389. let { data } = await getByCode('asset_level');
  390. this.assetLevel =
  391. data.length > 0
  392. ? data.map((item) => {
  393. return {
  394. name: Object.keys(item)[0],
  395. id: item[Object.keys(item)[0]]
  396. };
  397. })
  398. : [];
  399. },
  400. // 跳转到详情页
  401. add() {
  402. this.$router.push({
  403. path: '/ledgerAssets/office/edit'
  404. });
  405. },
  406. /* 表格数据源 */
  407. datasource({ page, limit, where, order }) {
  408. return getAssetList({
  409. ...where,
  410. ...order,
  411. pageNum: page,
  412. size: limit,
  413. categoryLevelId: this.categoryId,
  414. rootCategoryLevelId: this.rootId
  415. });
  416. },
  417. /* 刷新表格 */
  418. reload(where) {
  419. this.$refs.table.reload({ pageNum: 1, where: where });
  420. },
  421. // 刷新回调
  422. sucesstion(is) {
  423. console.log(is);
  424. if (is) {
  425. this.reload();
  426. }
  427. this.checkRadioData = [];
  428. },
  429. // 移动到
  430. moveTo(arr, type) {
  431. this.$refs.movetoRef.open(arr, this.current, type);
  432. },
  433. batchSettings(type) {
  434. let ids = this.checkRadioData.map((item) => {
  435. return item.id;
  436. });
  437. this.$refs.batchSetRef.open(type, ids);
  438. console.log(this.checkRadioData, 'checkRadioData 123');
  439. },
  440. allPrinting() {
  441. if (this.clientEnvironmentId == 2) {
  442. this.$refs.printSrRef.open(this.checkRadioData);
  443. } else if (this.clientEnvironmentId == 3) {
  444. this.$refs.printTgRef.open(this.checkRadioData);
  445. } else {
  446. this.$refs.printRef.open(this.checkRadioData);
  447. }
  448. },
  449. // 跳转到详情页
  450. details({ id, code }) {
  451. this.$router.push({
  452. path: '/ledgerAssets/office/detail',
  453. query: {
  454. id,
  455. code
  456. }
  457. });
  458. },
  459. // 跳转到编辑页
  460. goEdit({ id }) {
  461. this.$router.push({
  462. path: '/ledgerAssets/office/edit',
  463. query: {
  464. id
  465. }
  466. });
  467. },
  468. // 导出
  469. btnExport() {
  470. let params = {
  471. ...this.$refs.searchRef.where,
  472. exportType: 3,
  473. categoryLevelId: this.categoryId,
  474. rootCategoryLevelId: this.rootId
  475. };
  476. // downloadAsset(params, '模具台账导出数据');
  477. axios({
  478. url: `${API_BASE_URL}/main/asset/page/export`,
  479. method: 'post',
  480. responseType: 'blob',
  481. headers: {
  482. Authorization: getToken()
  483. },
  484. data: params
  485. }).then((res) => {
  486. download(res.data, '办公设备台账导出数据');
  487. });
  488. }
  489. },
  490. watch: {
  491. // 监听类别id变化
  492. categoryId() {
  493. this.reload();
  494. }
  495. }
  496. };
  497. </script>
  498. <style lang="scss" scoped>
  499. .ele-btn-icon {
  500. margin-left: 20px;
  501. }
  502. </style>