list.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <!-- 物料基础信息——列表 -->
  2. <template>
  3. <el-card class="material-list">
  4. <el-table v-loading="loading" :data="taskList" @cell-dblclick="handledbClick"
  5. @selection-change="handleSelectionChange">
  6. <el-table-column type="selection" width="55" />
  7. <el-table-column type="index" label="序号" width="55" align="center" />
  8. <el-table-column v-for="h in tableHeader" v-if="h.show" :label="h.name" align="center" :prop="h.prop"
  9. show-overflow-tooltip />
  10. </el-table>
  11. <!-- v-show="total > 0" -->
  12. <pagination :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  13. @pagination="getMaterialList" />
  14. </el-card>
  15. </template>
  16. <script>
  17. import materialApi from '@/api/material/basic';
  18. export default {
  19. name: 'material-list',
  20. data() {
  21. return {
  22. // 物料基本信息数据
  23. taskList: [],
  24. // 总条数
  25. total: 1,
  26. loading: false,
  27. // 查询参数
  28. queryParams: {
  29. pageNum: 1,
  30. pageSize: 10,
  31. code: null,
  32. name: null
  33. },
  34. // 表头
  35. tableHeader: [],
  36. // 多选数组
  37. checkedList: [],
  38. }
  39. },
  40. methods: {
  41. // 双击行
  42. handledbClick(e) {
  43. let bar = {
  44. address: 'materiaDetails',
  45. id: e.id,
  46. list: this.checkedList
  47. }
  48. this.$emit("actionBar", JSON.stringify(bar))
  49. },
  50. // 选中数据改变
  51. handleSelectionChange(list) {
  52. this.checkedList = list;
  53. this.$emit('headerOption', JSON.stringify({ checkedList: [...list] }))
  54. },
  55. // 获取物料列表信息
  56. getMaterialList(templateCode) {
  57. this.loading = true;
  58. materialApi.materialList({ templateCode }).then((res) => {
  59. this.loading = false;
  60. console.log(res, '获取物料列表信息以及表头字段');
  61. let { code, data } = res;
  62. if (code == 200) {
  63. this.taskList = data.tableBody.rows;
  64. this.total = data.tableBody.total;
  65. }
  66. })
  67. },
  68. // 获取物料列表表头
  69. getTagList(templateCode) {
  70. materialApi.tagList({ templateCode }).then(res => {
  71. console.log(res, '获取物料列表表头');
  72. if (res.code == 200) {
  73. this.tableHeader = res.data;
  74. }
  75. })
  76. },
  77. },
  78. created() {
  79. this.getMaterialList('material');
  80. this.getTagList('material');
  81. }
  82. }
  83. </script>
  84. <style>
  85. .material-list>>>.el-table__body-wrapper {
  86. height: 100%;
  87. }
  88. </style>