index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <div>
  3. <div style="margin: 10px 0; display: flex; align-items: center">
  4. <el-input
  5. class="input_content"
  6. placeholder="请输入内容"
  7. v-model="sourceList.pagination.keyword"
  8. style="width: 50%"
  9. clearable
  10. size="small"
  11. ></el-input>
  12. <el-select
  13. v-model="sourceList.pagination.purchaseStatus"
  14. clearable
  15. filterable
  16. style="width: 40%; margin-left: 10px"
  17. size="small"
  18. >
  19. <el-option
  20. v-for="(item, index) in statusData"
  21. :key="index"
  22. :value="item.value"
  23. :label="item.label"
  24. ></el-option>
  25. </el-select>
  26. <div style="text-align: center; width: 10%">
  27. <el-icon style="cursor: pointer" @click="getData"><Search /></el-icon>
  28. </div>
  29. </div>
  30. <el-table
  31. :data="sourceList.data"
  32. style="width: 100%; margin-top: 10px"
  33. v-loading="loading"
  34. :height="tableHeight"
  35. >
  36. <el-table-column prop="code" label="单号" width="100" fixed="left" />
  37. <el-table-column prop="createTime" label="日期" width="150" />
  38. <el-table-column prop="supplyName" label="供应商" min-width="150" />
  39. <el-table-column prop="amount" label="采购总价" width="100">
  40. <template #default="{ row }">
  41. <div>{{ moneyFormat(row.amount, 2) }}</div>
  42. </template>
  43. </el-table-column>
  44. <el-table-column
  45. prop="purchaseStatus"
  46. label="状态"
  47. width="100"
  48. :formatter="getStatus"
  49. />
  50. <!-- <el-table-column label="操作" width="60" fixed="right" align="center">
  51. <template #default="{ row }">
  52. <el-button type="primary" text
  53. ><i class="iconfont icon-iconm_wofqd"></i
  54. ></el-button>
  55. </template>
  56. </el-table-column> -->
  57. </el-table>
  58. <el-pagination
  59. style="margin-top: 10px"
  60. v-model:current-page="sourceList.pagination.pageNum"
  61. :page-size="10"
  62. layout="total, prev, pager, next"
  63. :total="sourceList.pagination.total"
  64. prev-text="上一页"
  65. next-text="下一页"
  66. @current-change="handleCurrentChange"
  67. />
  68. </div>
  69. </template>
  70. <script setup>
  71. const tableHeight = window.innerHeight - 209;
  72. const loading = ref(false);
  73. const sourceList = ref({
  74. data: [],
  75. pagination: {
  76. total: 300,
  77. pageNum: 1,
  78. pageSize: 10,
  79. },
  80. });
  81. const statusData = ref([
  82. {
  83. label: "审批中",
  84. value: "10",
  85. },
  86. {
  87. label: "驳回",
  88. value: "20",
  89. },
  90. {
  91. label: "已采购",
  92. value: "30",
  93. },
  94. {
  95. label: "终止",
  96. value: "99",
  97. },
  98. {
  99. label: "已作废",
  100. value: "88",
  101. },
  102. ]);
  103. const { proxy } = getCurrentInstance();
  104. const getStatus = (row) => {
  105. const current = statusData.value.find((x) => x.value == row.purchaseStatus);
  106. if (current) return current.label;
  107. };
  108. const getData = () => {
  109. loading.value = true;
  110. proxy.post("/purchase/page", sourceList.value.pagination).then((res) => {
  111. sourceList.value.data = res.rows;
  112. sourceList.value.pagination.total = res.total;
  113. setTimeout(() => {
  114. loading.value = false;
  115. }, 200);
  116. });
  117. };
  118. const handleCurrentChange = (val) => {
  119. sourceList.value.pagination.pageNum = val;
  120. getData();
  121. };
  122. getData();
  123. onMounted(() => {});
  124. </script>
  125. <style lang="scss" scoped>
  126. * {
  127. font-size: 12px;
  128. }
  129. .el-button {
  130. padding: 0px;
  131. }
  132. .btn {
  133. width: 100%;
  134. border-radius: 10px;
  135. padding: 6px 10px;
  136. height: 24px;
  137. }
  138. .el-pagination {
  139. padding-left: 30px;
  140. }
  141. :deep(.el-pagination button, .el-pager li) {
  142. font-size: 12px;
  143. }
  144. :deep(.el-table .el-table__cell) {
  145. padding: 2px 0px;
  146. }
  147. </style>