data-list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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. </template>
  51. <!-- 编码列 -->
  52. <template v-slot:code="{ row }">
  53. <el-link type="primary" :underline="false" @click="details(row)">
  54. {{ row.code }}
  55. </el-link>
  56. </template>
  57. <!-- 牌号列 -->
  58. <template v-slot:brandNum="{ row }">
  59. <div>
  60. {{ row.category.brandNum }}
  61. </div>
  62. </template>
  63. <!-- 型号列 -->
  64. <template v-slot:modelType="{ row }">
  65. <div>
  66. {{ row.category.modelType }}
  67. </div>
  68. </template>
  69. <!-- 分类列 -->
  70. <template v-slot:categoryLevelPath="{ row }">
  71. <div>
  72. {{ row.category.categoryLevelPath }}
  73. </div>
  74. </template>
  75. <!-- 操作列 -->
  76. <template v-slot:action="{ row }">
  77. <el-link
  78. type="primary"
  79. :underline="false"
  80. icon="el-icon-edit"
  81. @click="goEdit(row)"
  82. >
  83. 编辑
  84. </el-link>
  85. </template>
  86. </ele-pro-table>
  87. <print ref="printRef"></print>
  88. <printSr ref="printSrRef"></printSr>
  89. <printTg ref="printTgRef"></printTg>
  90. </div>
  91. </template>
  92. <script>
  93. import print from '@/views/ledgerAssets/components/print.vue';
  94. import printSr from '@/views/ledgerAssets/components/printSr';
  95. import printTg from '@/views/ledgerAssets/components/printTg';
  96. import { getByCode } from '@/api/system/dictionary-data';
  97. import {
  98. businessStatus,
  99. networkStatus,
  100. sourceStatus
  101. } from '@/utils/dict/warehouse';
  102. import UserSearch from './user-search.vue';
  103. import { getAssetList, downloadAsset } from '@/api/ledgerAssets';
  104. import dictMixins from '@/mixins/dictMixins';
  105. import axios from 'axios';
  106. import {
  107. API_BASE_URL,
  108. TOKEN_HEADER_NAME,
  109. LAYOUT_PATH
  110. } from '@/config/setting';
  111. import { download } from '@/utils/file';
  112. import { getToken, setToken } from '@/utils/token-util';
  113. export default {
  114. components: { UserSearch, print, printSr, printTg },
  115. mixins: [dictMixins],
  116. props: {
  117. // 类别id
  118. categoryId: [Number, String],
  119. rootId: [Number, String]
  120. },
  121. data() {
  122. return {
  123. checkRadioData: [],
  124. QRvisible: false,
  125. networkStatus,
  126. businessStatus,
  127. assetLevel: [],
  128. isConsumer: false,
  129. networkCounts: {},
  130. // 表格列配置
  131. columns: [
  132. {
  133. width: 45,
  134. type: 'selection',
  135. columnKey: 'selection',
  136. align: 'center'
  137. },
  138. {
  139. columnKey: 'index',
  140. type: 'index',
  141. label: '序号',
  142. width: 55,
  143. align: 'center',
  144. showOverflowTooltip: true,
  145. fixed: 'left'
  146. },
  147. {
  148. columnKey: 'code',
  149. prop: 'code',
  150. slot: 'code',
  151. label: '编码',
  152. showOverflowTooltip: true,
  153. minWidth: 180
  154. },
  155. // {
  156. // columnKey: 'code',
  157. // prop: 'code',
  158. // label: '设备编码',
  159. // showOverflowTooltip: true,
  160. // minWidth: 110,
  161. // slot: 'code'
  162. // },
  163. {
  164. prop: 'name',
  165. label: '名称',
  166. showOverflowTooltip: true,
  167. minWidth: 110
  168. },
  169. {
  170. prop: 'fixCode',
  171. label: '固资编码',
  172. showOverflowTooltip: true,
  173. minWidth: 110
  174. },
  175. {
  176. prop: 'postName',
  177. label: '使用岗位',
  178. showOverflowTooltip: true,
  179. minWidth: 110
  180. },
  181. {
  182. prop: 'codeNumber',
  183. label: '编号',
  184. showOverflowTooltip: true,
  185. minWidth: 110
  186. },
  187. // {
  188. // prop: 'codeNumber',
  189. // label: '编号',
  190. // showOverflowTooltip: true,
  191. // minWidth: 110
  192. // },
  193. {
  194. prop: 'category.modelType',
  195. label: '型号',
  196. showOverflowTooltip: true,
  197. minWidth: 110
  198. },
  199. {
  200. prop: 'category.specification',
  201. label: '规格',
  202. showOverflowTooltip: true,
  203. minWidth: 110
  204. },
  205. {
  206. prop: 'usePerson',
  207. label: '使用人',
  208. showOverflowTooltip: true,
  209. minWidth: 80
  210. },
  211. {
  212. prop: 'chargePerson',
  213. label: '负责人',
  214. showOverflowTooltip: true,
  215. minWidth: 80
  216. },
  217. {
  218. prop: 'endTime',
  219. label: '有效期结束时间',
  220. showOverflowTooltip: true,
  221. minWidth: 150
  222. },
  223. {
  224. prop: 'source',
  225. label: '生命周期',
  226. showOverflowTooltip: true,
  227. minWidth: 110,
  228. formatter: (_row) => {
  229. return sourceStatus[_row.lifeCycle];
  230. }
  231. },
  232. {
  233. prop: 'level',
  234. label: '级别',
  235. showOverflowTooltip: true,
  236. minWidth: 110,
  237. formatter: (_row) => {
  238. if (_row.level) {
  239. return this.assetLevel.filter(
  240. (item) => item.id == _row.level
  241. )[0].name;
  242. } else {
  243. return '';
  244. }
  245. }
  246. },
  247. {
  248. prop: 'networkStatus',
  249. label: '网络状态',
  250. showOverflowTooltip: true,
  251. minWidth: 110,
  252. formatter: (_row) => {
  253. console.log('_row.networkStatus-------', _row.networkStatus);
  254. if (_row.networkStatus) {
  255. return this.networkStatus.filter(
  256. (item) => item.code == _row.networkStatus
  257. )[0].label;
  258. } else {
  259. return '离线';
  260. }
  261. }
  262. },
  263. {
  264. prop: 'status',
  265. label: '状态',
  266. showOverflowTooltip: true,
  267. minWidth: 110,
  268. formatter: (_row) => {
  269. if (_row.status) {
  270. return this.businessStatus.filter(
  271. (item) => item.code == _row.status
  272. )[0].label;
  273. } else {
  274. return '空闲';
  275. }
  276. }
  277. },
  278. {
  279. prop: 'pathName',
  280. label: '位置',
  281. showOverflowTooltip: true,
  282. minWidth: 110,
  283. formatter: (_row) => {
  284. const positionDetail =
  285. _row.position &&
  286. _row.position.length != 0 &&
  287. _row.position[0].detailPosition
  288. ? _row.position[0].detailPosition
  289. : '-';
  290. return _row.deviceLocationName
  291. ? _row.deviceLocationName + '-' + positionDetail
  292. : '';
  293. }
  294. },
  295. {
  296. columnKey: 'action',
  297. slot: 'action',
  298. label: '操作',
  299. minWidth: 100,
  300. fixed: 'right'
  301. }
  302. ]
  303. };
  304. },
  305. computed: {
  306. clientEnvironmentId() {
  307. return this.$store.state.user.info.clientEnvironmentId;
  308. }
  309. },
  310. created() {
  311. this.requestDict('生命周期');
  312. this.getAssetLevelOptions();
  313. },
  314. methods: {
  315. allPrinting() {
  316. if (this.clientEnvironmentId == 2) {
  317. this.$refs.printSrRef.open(this.checkRadioData);
  318. } else if (this.clientEnvironmentId == 3) {
  319. this.$refs.printTgRef.open(this.checkRadioData);
  320. } else {
  321. this.$refs.printRef.open(this.checkRadioData);
  322. }
  323. },
  324. // 全选
  325. changeSelectAll(arr) {
  326. console.log(arr);
  327. if (arr.length != 0) {
  328. this.checkRadioData = arr;
  329. } else {
  330. this.checkRadioData = [];
  331. }
  332. },
  333. selectChange(selection, row) {
  334. if (selection.length != 0) {
  335. this.checkRadioData = selection;
  336. } else {
  337. this.checkRadioData = [];
  338. }
  339. },
  340. // 获取资产级别下拉
  341. async getAssetLevelOptions() {
  342. let { data } = await getByCode('asset_level');
  343. this.assetLevel =
  344. data.length > 0
  345. ? data.map((item) => {
  346. return {
  347. name: Object.keys(item)[0],
  348. id: item[Object.keys(item)[0]]
  349. };
  350. })
  351. : [];
  352. },
  353. // 跳转到详情页
  354. add() {
  355. this.$router.push({
  356. path: '/ledgerAssets/office/edit'
  357. });
  358. },
  359. /* 表格数据源 */
  360. datasource({ page, limit, where, order }) {
  361. return getAssetList({
  362. ...where,
  363. ...order,
  364. pageNum: page,
  365. size: limit,
  366. categoryLevelId: this.categoryId,
  367. rootCategoryLevelId: this.rootId
  368. });
  369. },
  370. /* 刷新表格 */
  371. reload(where) {
  372. this.$refs.table.reload({ pageNum: 1, where: where });
  373. },
  374. // 跳转到详情页
  375. details({ id, code }) {
  376. this.$router.push({
  377. path: '/ledgerAssets/office/detail',
  378. query: {
  379. id,
  380. code
  381. }
  382. });
  383. },
  384. // 跳转到编辑页
  385. goEdit({ id }) {
  386. this.$router.push({
  387. path: '/ledgerAssets/office/edit',
  388. query: {
  389. id
  390. }
  391. });
  392. },
  393. // 导出
  394. btnExport() {
  395. let params = {
  396. ...this.$refs.searchRef.where,
  397. exportType: 3,
  398. categoryLevelId: this.categoryId,
  399. rootCategoryLevelId: this.rootId
  400. };
  401. // downloadAsset(params, '模具台账导出数据');
  402. axios({
  403. url: `${API_BASE_URL}/main/asset/page/export`,
  404. method: 'post',
  405. responseType: 'blob',
  406. headers: {
  407. Authorization: getToken()
  408. },
  409. data: params
  410. }).then((res) => {
  411. download(res.data, '办公设备台账导出数据');
  412. });
  413. }
  414. },
  415. watch: {
  416. // 监听类别id变化
  417. categoryId() {
  418. this.reload();
  419. }
  420. }
  421. };
  422. </script>
  423. <style lang="scss" scoped>
  424. .ele-btn-icon {
  425. margin-left: 20px;
  426. }
  427. </style>