|
|
@@ -1,61 +1,21 @@
|
|
|
-import { ColumnType, getTableHead } from '@/common/methods/table';
|
|
|
-import { TableKey } from '@/common/methods/table/interface';
|
|
|
+import { Column, ColumnType } from '@/common/setup/table/index';
|
|
|
import { QueryPurchase } from '@/services/go/ermcp/purchase/index';
|
|
|
import { Ermcp3SellBuyContract, Querytype } from '@/services/go/ermcp/purchase/interface';
|
|
|
import { message } from 'ant-design-vue';
|
|
|
import { ref } from 'vue';
|
|
|
|
|
|
-// 列表
|
|
|
-export function getTableList(tableKey: keyof TableKey) {
|
|
|
+/**
|
|
|
+ * 获取表格列表数据
|
|
|
+ * @param type
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+export function queryTableList(type: Querytype) {
|
|
|
+ // 加载状态
|
|
|
+ const loading = ref<boolean>(false);
|
|
|
// 表格数据
|
|
|
const tableList = ref<Ermcp3SellBuyContract[]>([]);
|
|
|
- // 表头数据
|
|
|
- const columns = ref<ColumnType[]>([]);
|
|
|
- // 过滤项
|
|
|
- const filteredInfo = ref();
|
|
|
- const loading = ref<boolean>(false);
|
|
|
- // 获取表头
|
|
|
- function getColumns() {
|
|
|
- const list = getTableHead(tableKey);
|
|
|
- const filtered = filteredInfo.value || {};
|
|
|
- columns.value.length = 0;
|
|
|
- list.forEach((e, i) => {
|
|
|
- const { columnfield, columntitle, aligntype } = e;
|
|
|
- const item: ColumnType = {
|
|
|
- key: String(i),
|
|
|
- dataIndex: columnfield, // 表格数据对应的key
|
|
|
- title: columntitle,
|
|
|
- align: aligntype === 1 ? 'center' : aligntype === 2 ? 'left' : 'right',
|
|
|
- slots: { customRender: columnfield },
|
|
|
- };
|
|
|
- // // 以下添加过滤数据对应的方法
|
|
|
- if (e.columnfield === 'accountname') {
|
|
|
- item.onFilter = (value: string, record: Ermcp3SellBuyContract) => record.accountname.includes(value);
|
|
|
- item.filteredValue = filtered.accountname || null;
|
|
|
- }
|
|
|
- if (e.columnfield === 'contractno') {
|
|
|
- item.onFilter = (value: string, record: Ermcp3SellBuyContract) => record.contractno.includes(value);
|
|
|
- item.filteredValue = filtered.contractno || null;
|
|
|
- }
|
|
|
- if (e.columnfield === 'deliverygoodsname') {
|
|
|
- item.onFilter = (value: string, record: Ermcp3SellBuyContract) => record.deliverygoodsname.includes(value);
|
|
|
- item.filteredValue = filtered.deliverygoodsname || null;
|
|
|
- }
|
|
|
- if (e.columnfield === 'convertfactor') {
|
|
|
- item.onFilter = (value: string, record: Ermcp3SellBuyContract) => String(record.convertfactor).includes(value);
|
|
|
- item.filteredValue = filtered.convertfactor || null;
|
|
|
- }
|
|
|
- if (e.columnfield === 'goodsname') {
|
|
|
- item.onFilter = (value: string, record: Ermcp3SellBuyContract) => record.goodsname.includes(value);
|
|
|
- item.filteredValue = filtered.goodsname || null;
|
|
|
- }
|
|
|
- columns.value.push(item);
|
|
|
- });
|
|
|
- }
|
|
|
- // 查询列表
|
|
|
- function actionQuery(querytype: Querytype) {
|
|
|
- loading.value = true;
|
|
|
- QueryPurchase({ querytype })
|
|
|
+ function queryTable() {
|
|
|
+ QueryPurchase({ querytype: type })
|
|
|
.then((res) => {
|
|
|
tableList.value = res.map((e, i) => {
|
|
|
return { ...e, key: String(i) };
|
|
|
@@ -68,11 +28,35 @@ export function getTableList(tableKey: keyof TableKey) {
|
|
|
loading.value = false;
|
|
|
});
|
|
|
}
|
|
|
- // 查询
|
|
|
- function search(value: any) {
|
|
|
- filteredInfo.value = value;
|
|
|
- getColumns();
|
|
|
- }
|
|
|
+ return { loading, tableList, queryTable }
|
|
|
+}
|
|
|
|
|
|
- return { tableList, actionQuery, columns, filteredInfo, getColumns, search, loading, };
|
|
|
-}
|
|
|
+/**
|
|
|
+ * 过滤表格的回调函数
|
|
|
+ * @param e
|
|
|
+ * @param item
|
|
|
+ * @param filtered
|
|
|
+ */
|
|
|
+export function getFilterTableCB(e: Column, item: ColumnType, filtered: any) {
|
|
|
+ // // 以下添加过滤数据对应的方法
|
|
|
+ if (e.columnfield === 'accountname') {
|
|
|
+ item.onFilter = (value: string, record: Ermcp3SellBuyContract) => record.accountname.includes(value);
|
|
|
+ item.filteredValue = filtered.accountname || null;
|
|
|
+ }
|
|
|
+ if (e.columnfield === 'contractno') {
|
|
|
+ item.onFilter = (value: string, record: Ermcp3SellBuyContract) => record.contractno.includes(value);
|
|
|
+ item.filteredValue = filtered.contractno || null;
|
|
|
+ }
|
|
|
+ if (e.columnfield === 'deliverygoodsname') {
|
|
|
+ item.onFilter = (value: string, record: Ermcp3SellBuyContract) => record.deliverygoodsname.includes(value);
|
|
|
+ item.filteredValue = filtered.deliverygoodsname || null;
|
|
|
+ }
|
|
|
+ if (e.columnfield === 'convertfactor') {
|
|
|
+ item.onFilter = (value: string, record: Ermcp3SellBuyContract) => String(record.convertfactor).includes(value);
|
|
|
+ item.filteredValue = filtered.convertfactor || null;
|
|
|
+ }
|
|
|
+ if (e.columnfield === 'goodsname') {
|
|
|
+ item.onFilter = (value: string, record: Ermcp3SellBuyContract) => record.goodsname.includes(value);
|
|
|
+ item.filteredValue = filtered.goodsname || null;
|
|
|
+ }
|
|
|
+}
|