materialsDeclaration.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <div class="app-container">
  3. <div v-show="!materialsDeclarationViewState.show && !materialsDeclarationAddState.show">
  4. <el-row :gutter="10" class="mb8">
  5. <el-col :span="1.5">
  6. <el-button type="primary" icon="Plus" @click="handleAdd">新增采购</el-button>
  7. </el-col>
  8. </el-row>
  9. <!-- 表格组件 -->
  10. <el-table ref="multipleTable" v-loading="loading" :data="tableData" style="width: 100%" :max-height="400">
  11. <el-table-column label="序号" align="center" width="55" fixed="left">
  12. <template #default="scope">
  13. {{ (queryParams.page - 1) * queryParams.pageSize + scope.$index + 1 }}
  14. </template>
  15. </el-table-column>
  16. <el-table-column label="申报日期" align="center" prop="declaration_date" />
  17. <el-table-column label="申报金额(元)" align="center" prop="declaration_amount" />
  18. <el-table-column label="申报单位" align="center" prop="declaration_unit_name" />
  19. <el-table-column label="申报人" align="center" prop="declaration_person_name" />
  20. <el-table-column label="审批情况" align="center" prop="declaration_details">
  21. <template #default="scope">
  22. {{ getApprovalStatusText(scope.row.declaration_details) }}
  23. </template>
  24. </el-table-column>
  25. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="200">
  26. <template #default="scope">
  27. <el-text class="common-btn-text-primary" @click="handleView(scope.row)">详情</el-text>
  28. <el-text v-if="scope.row.declaration_details === '1'" class="common-btn-text-primary" @click="handleUpdate(scope.row)">编辑</el-text>
  29. </template>
  30. </el-table-column>
  31. </el-table>
  32. <pagination
  33. v-show="total > 0"
  34. v-model:page="queryParams.page"
  35. v-model:limit="queryParams.pageSize"
  36. :total="total"
  37. @pagination="fetchWorkrData"
  38. />
  39. </div>
  40. <MaterialsDeclarationView v-if="materialsDeclarationViewState.show" :id="materialsDeclarationViewState.id" @close="handleCancel" />
  41. <MaterialsDeclarationAdd v-if="materialsDeclarationAddState.show" :id="materialsDeclarationAddState.id" @close="handleCancel" />
  42. </div>
  43. </template>
  44. <script setup lang="ts">
  45. import { getDeclarationList } from '@/api/comprehensiveGuarantee/materialReserveManagement/materialsDeclaration';
  46. import Pagination from '@/components/Pagination/index.vue'; // 假设这是分页组件的路径
  47. import MaterialsDeclarationView from './materialsDeclarationView.vue'; // 查看详情组件
  48. import MaterialsDeclarationAdd from './materialsDeclarationAdd.vue';
  49. const loading = ref(true);
  50. const total = ref(0);
  51. const tableData = ref<any[]>([]);
  52. const initFormData = reactive({
  53. declaration_date: '',
  54. declaration_amount: '',
  55. declaration_unit_name: '',
  56. declaration_person_name: '',
  57. declaration_details: ''
  58. });
  59. const data = reactive({
  60. form: { ...initFormData },
  61. queryParams: {
  62. page: 1,
  63. pageSize: 10
  64. }
  65. });
  66. const { queryParams, form } = toRefs(data);
  67. // 获取物资申报列表
  68. const fetchWorkrData = () => {
  69. loading.value = true;
  70. getDeclarationList(queryParams.value)
  71. .then((res) => {
  72. tableData.value = res.data;
  73. total.value = res.total;
  74. })
  75. .finally(() => {
  76. loading.value = false;
  77. });
  78. };
  79. const handleQuery = () => {
  80. queryParams.value.page = 1;
  81. fetchWorkrData();
  82. };
  83. const resetQuery = () => {
  84. queryParams.value = { page: 1, pageSize: 10 };
  85. handleQuery();
  86. };
  87. let materialsDeclarationViewState = reactive({
  88. show: false,
  89. id: ''
  90. });
  91. let materialsDeclarationAddState = reactive({
  92. show: false,
  93. id: ''
  94. });
  95. const handleAdd = () => {
  96. materialsDeclarationAddState.id = '';
  97. materialsDeclarationAddState.show = true;
  98. };
  99. const handleUpdate = (row: any) => {
  100. materialsDeclarationAddState.id = row.id;
  101. materialsDeclarationAddState.show = true;
  102. };
  103. const handleView = (row: any) => {
  104. materialsDeclarationViewState.id = row.id;
  105. materialsDeclarationViewState.show = true;
  106. };
  107. const handleCancel = (needUpdate) => {
  108. materialsDeclarationViewState.show = false;
  109. materialsDeclarationAddState.show = false;
  110. if (!!needUpdate) {
  111. handleQuery();
  112. }
  113. };
  114. // 定义审批状态映射
  115. const approvalStatusMap = {
  116. '1': '未审核',
  117. '2': '通过',
  118. '3': '不通过'
  119. };
  120. // 方法用于将数字转换为对应的审批状态文本
  121. const getApprovalStatusText = (status: string) => {
  122. return approvalStatusMap[status] || '未知';
  123. };
  124. onMounted(() => {
  125. fetchWorkrData();
  126. });
  127. </script>
  128. <style scoped>
  129. .app-container {
  130. overflow-x: auto; /* 当内容溢出时允许水平滚动 */
  131. }
  132. </style>