曹睿
昨天 344551aecaab6762c7dc7b4b4f85bbff18898ab9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<template>
  <div class="app-container">
    <div class="search_form">
      <el-form :model="filters" :inline="true">
        <el-form-item label="采购合同号:">
          <el-input
            v-model="filters.purchaseContractNumber"
            placeholder="请输入"
            clearable
            prefix-icon="Search"
            @change="getTableData"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="getTableData"> 搜索 </el-button>
          <el-button @click="resetFilters"> 重置 </el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="table_list">
      <div class="actions">
        <div></div>
        <div>
          <el-button type="primary" @click="handleAdd('add')">
            新增登记
          </el-button>
          <el-button @click="handleOut">导出</el-button>
          <el-button type="danger" plain @click="handleDelete">删除</el-button>
        </div>
      </div>
      <PIMTable
        rowKey="id"
        :column="columns"
        :tableData="dataList"
        :tableLoading="loading"
        :isSelection="true"
        :page="{
          current: pagination.currentPage,
          size: pagination.pageSize,
          total: pagination.total,
        }"
        :expand-row-keys="expandRowKeys"
        @expand-change="expandChange"
        @selection-change="handleSelectionChange"
        @pagination="onCurrentChange"
      >
        <template #expand="{ row }">
          <ExpandTable ref="expandTableRef" />
        </template>
        <template #operation="{ row }">
          <el-button
            text
            type="primary"
            size="small"
            @click="handleEdit('edit', row.id)"
          >
            编辑
          </el-button>
        </template>
      </PIMTable>
    </div>
    <Modal ref="modalRef"></Modal>
  </div>
</template>
 
<script setup>
import { usePaginationApi } from "@/hooks/usePaginationApi";
import { gePurchaseListPage } from "@/api/procurementManagement/invoiceEntry.js";
import { nextTick, onMounted, getCurrentInstance } from "vue";
import ExpandTable from "./components/ExpandTable.vue";
import Modal from "./components/Modal.vue";
 
defineOptions({
  name: "来票登记",
});
 
const { proxy } = getCurrentInstance();
const expandRowKeys = ref([]);
const expandTableRef = ref();
const modalRef = ref();
const selectedRows = ref([]);
 
const {
  loading,
  filters,
  columns,
  dataList,
  pagination,
  getTableData,
  resetFilters,
  onCurrentChange,
} = usePaginationApi(
  gePurchaseListPage,
  {
    purchaseContractNumber: undefined,
  },
  [
    {
      type: "expand",
      dataType: "slot",
      slot: "expand",
    },
    {
      label: "采购订单号",
      prop: "purchaseContractNumber",
    },
    {
      label: "销售合同号",
      prop: "salesContractNo",
    },
    {
      label: "供应商名称",
      prop: "supplierName",
    },
    {
      label: "项目名称",
      prop: "projectName",
    },
    {
      label: "录入人",
      prop: "recorderName",
    },
    {
      label: "录入日期",
      prop: "entryDate",
    },
    {
      label: "合同金额(元)",
      prop: "contractAmount",
      formatData: (val) => {
        return val ? parseFloat(val).toFixed(2) : 0;
      },
    },
    {
      label: "已开票金额(元)",
      prop: "receiptPaymentAmount",
      formatData: (val) => {
        return val ? parseFloat(val).toFixed(2) : 0;
      },
    },
    {
      label: "待开票金额(元)",
      prop: "unReceiptPaymentAmount",
      formatData: (val) => {
        return val ? parseFloat(val).toFixed(2) : 0;
      },
    },
    // {
    //   fixed: "right",
    //   label: "操作",
    //   dataType: "slot",
    //   slot: "operation",
    //   align: "center",
    //   width: "200px",
    // },
  ]
);
 
const handleSelectionChange = (selection) => {
  selectedRows.value = selection.filter(
    (item) => item.purchaseContractNumber !== undefined
  );
};
 
const handleAdd = (type) => {
  if (selectedRows.value.length !== 1) {
    proxy.$modal.msgWarning("请先选中一条数据");
    return;
  }
  modalRef.value.open(type, selectedRows.value[0].id);
};
 
const handleEdit = (type, id) => {
  modalRef.value.open(type, id);
};
 
const handleOut = () => {};
const handleDelete = () => {};
 
const expandChange = async (row, expandedRows) => {
  await nextTick();
  expandTableRef.value.getList(row.id);
};
 
onMounted(() => {
  getTableData();
});
</script>
 
<style lang="scss" scoped>
.table_list {
  margin-top: unset;
}
.actions {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}
</style>