|
|
@@ -1,84 +1,54 @@
|
|
|
-import { ColumnType, getTableHead } from '@/common/methods/table';
|
|
|
-import { QuerySpotContract } from '@/services/go/ermcp/spot-contract/index';
|
|
|
-import { Ermcp3ContractRsp } from '@/services/go/ermcp/spot-contract/interface';
|
|
|
+import { Column, ColumnType } from '@/common/setup/table/index';
|
|
|
+import { QueryHedgePlan } from '@/services/go/ermcp/plan';
|
|
|
+import { Ermcp3HedgePlan } from '@/services/go/ermcp/plan/interface';
|
|
|
import { message } from 'ant-design-vue';
|
|
|
import { ref } from 'vue';
|
|
|
|
|
|
-// 处理现货列表
|
|
|
-export function getCustomList() {
|
|
|
- // 表格数据
|
|
|
- const spotContractList = ref<Ermcp3ContractRsp[]>([]);
|
|
|
- // 表头数据
|
|
|
- const columns = ref<ColumnType[]>([]);
|
|
|
- // 过滤项
|
|
|
- const filteredInfo = ref();
|
|
|
+/**
|
|
|
+ * 获取表格列表数据
|
|
|
+ * @param type
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+export function queryTableList(type: string) {
|
|
|
+ // 加载状态
|
|
|
const loading = ref<boolean>(false);
|
|
|
- // 获取表头
|
|
|
- function getColumns() {
|
|
|
- const list = getTableHead('table_pcweb_delivery');
|
|
|
- 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.columntitle === '类型') {
|
|
|
- item.onFilter = (value: string, record: Ermcp3ContractRsp) => String(record.contracttype).includes(value);
|
|
|
- item.filteredValue = filtered.contracttype || null;
|
|
|
- }
|
|
|
- if (e.columntitle === '定价类型') {
|
|
|
- item.onFilter = (value: string, record: Ermcp3ContractRsp) => String(record.pricetype).includes(value);
|
|
|
- item.filteredValue = filtered.pricetype || null;
|
|
|
- }
|
|
|
- if (e.columntitle === '合同编号') {
|
|
|
- item.onFilter = (value: string, record: Ermcp3ContractRsp) => record.contractno.includes(value);
|
|
|
- item.filteredValue = filtered.contractno || null;
|
|
|
- }
|
|
|
- if (e.columntitle === '对手方') {
|
|
|
- item.onFilter = (value: string, record: Ermcp3ContractRsp) => {
|
|
|
- if (record.contracttype === 1) {
|
|
|
- //采购方
|
|
|
- return record.sellusername.includes(value);
|
|
|
- } else {
|
|
|
- // 销售
|
|
|
- return record.buyusername.includes(value);
|
|
|
- }
|
|
|
- };
|
|
|
- item.filteredValue = filtered.negative || null;
|
|
|
- }
|
|
|
- columns.value.push(item);
|
|
|
- });
|
|
|
- console.log('columns', columns);
|
|
|
- }
|
|
|
- // 1-未提交 2-待审核 3-履约中 4-已完成
|
|
|
- type EnumType = 1 | 2 | 3 | 4;
|
|
|
- // 查询列表
|
|
|
- function actionQuery(type: EnumType) {
|
|
|
- loading.value = true;
|
|
|
- QuerySpotContract({ querytype: type })
|
|
|
+ // 表格数据
|
|
|
+ const tableList = ref<Ermcp3HedgePlan[]>([]);
|
|
|
+ function queryTable() {
|
|
|
+ QueryHedgePlan(type)
|
|
|
.then((res) => {
|
|
|
- spotContractList.value = res.map((e, i) => {
|
|
|
+ tableList.value = res.map((e, i) => {
|
|
|
return { ...e, key: String(i) };
|
|
|
});
|
|
|
loading.value = false;
|
|
|
- console.log('查询列表', spotContractList);
|
|
|
+ console.log('查询列表', tableList);
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
message.error(err);
|
|
|
loading.value = false;
|
|
|
});
|
|
|
}
|
|
|
- // 查询
|
|
|
- function search(value: any) {
|
|
|
- filteredInfo.value = value;
|
|
|
- getColumns();
|
|
|
- }
|
|
|
-
|
|
|
- return { spotContractList, actionQuery, columns, filteredInfo, getColumns, search, loading };
|
|
|
+ return { loading, tableList, queryTable }
|
|
|
}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 过滤表格的回调函数
|
|
|
+ * @param e
|
|
|
+ * @param item
|
|
|
+ * @param filtered
|
|
|
+ */
|
|
|
+export function getFilterTableCB(e: Column, item: ColumnType, filtered: any) {
|
|
|
+ // // 以下添加过滤数据对应的方法
|
|
|
+ if (e.columnfield === 'contracttype') {
|
|
|
+ item.onFilter = (value: string, record: Ermcp3HedgePlan) => String(record.contracttype).includes(String(value));
|
|
|
+ item.filteredValue = filtered.contracttype || null;
|
|
|
+ }
|
|
|
+ if (e.columnfield === 'hedgeplanno') {
|
|
|
+ item.onFilter = (value: string, record: Ermcp3HedgePlan) => record.hedgeplanno.includes(value);
|
|
|
+ item.filteredValue = filtered.hedgeplanno || null;
|
|
|
+ }
|
|
|
+ if (e.columnfield === 'deliverygoodsname') {
|
|
|
+ item.onFilter = (value: string, record: Ermcp3HedgePlan) => record.deliverygoodsname.includes(value);
|
|
|
+ item.filteredValue = filtered.deliverygoodsname || null;
|
|
|
+ }
|
|
|
+}
|