<template>
	<div class="system-user-container layout-padding">
		<el-card class="layout-padding-auto" shadow="hover">
			<avue-crud
          ref="crudRef"
          :data="state.data"
          :option="state.option"
          v-model:page="state.page"
          v-model:search="state.formData"
          @on-load="onLoadFun"
          @search-change="searchChange"
          @search-reset="resetChange"
      >
				<template #menu>
          <div class="btnList">
<!--            <el-button type="text" icon="el-icon-pie-chart" @click="toPurchaseDetails">查看详情</el-button>-->
            <el-button type="text" icon="el-icon-pie-chart" @click="state.selectedDataShow = true">查看单据</el-button>
          </div>
				</template>
			</avue-crud>
		</el-card>
    <selectedData :showes="state.selectedDataShow"/>
	</div>
</template>

<script lang="ts" setup>
import { reactive, onMounted,computed } from 'vue';
import { useRouter } from 'vue-router'
import { useI18n } from 'vue-i18n';
import selectedData from './selectedData.vue'
import {listApi} from "/@/api/list";
const router = useRouter()
const { t } = useI18n();

// 定义变量内容
const state = reactive({
	page: {
		total: 1000,
		currentPage: 1,
		pageSize: 10,
	},
	option: {
		index: false,
		menuWidth: 150,
		border: true,
		delBtn: false,
		editBtn: false,
		align: 'center',
    searchLabelWidth:120,
    searchMenuSpan:6,
    addBtn:false,
		column: [
			{ label: '采购订单号', prop: 'purchaseOrderFBillNo', width: 200,search: true },
			{ label: '发货单号', prop: 'sheet', width: 200,search: true },
			{ label: computed(() => t('message.list.PONumber2')), prop: 'fBillNo', width: 200,search: true },
			{ label: computed(() => t('message.list.SupplierCode2')), prop: 'supplierId', width: 200,search: true },
			{ label: computed(() => t('message.list.SupplierName2')), prop: 'supplierName', width: 200,search: true },
			{ label: computed(() => t('message.list.Buyer2')), prop: 'FPurchaserId', width: 200,search: true },
      // { label: computed(() => t('message.list.ReceiveOrg')), prop: 'FStockOrgId', width: 200,search: true },
      // { label: computed(() => t('message.list.BusinessType')), prop: 'FBillTypeID', width: 200,search: true },
      // { label: computed(() => t('message.list.OrderCreator')), prop: 'FCreatorId', width: 200,search: true },
      { label: computed(() => t('message.list.DocStatus2')), prop: 'FDocumentStatus', width: 200,search: true },
      { label: computed(() => t('message.list.ReceivingDate')), prop: 'fDate', width: 200,search: true,type: 'datetime', searchSpan: 12,searchRange: true,},
			// { label: computed(() => t('message.list.Comments3')), prop: 'FRemarks', width: 200 },
		],
	},
	data: [],
  selectedDataShow:false,
  formData:{}
});
const toPurchaseDetails = () => {
  router.push({
    path: '/materialReceiptNoticePurchaseDetails',
  })
}
const onLoadFun = (e:any) => {
  state.page.currentPage = e.currentPage
  state.page.pageSize = e.pageSize
  getList()
}
const searchChange = (params:any, done:any) => {
  done()
  if(params.fDate?.length){
    console.log(11111)
  }
}
const resetChange = () => {

}
const getList = () => {
  listApi().invoiceOrderGetPageList({
    ...state.formData,
    pageSize:state.page.pageSize,
    page:state.page.currentPage,
  }).then((res:any) => {
    if(res.resultCode === 0){
      state.data = res.data.dataList
      state.page.total = res.data.total
    }
  })
}
// 页面加载时
onMounted(() => {
  getList()
});
</script>

<style lang="scss" scoped>
.system-user-container {
	:deep(.el-card__body) {
		display: flex;
		flex-direction: column;
		flex: 1;
		overflow: auto;

		.el-table {
			flex: 1;
		}
	}
}
:deep(.el-col){
  margin-bottom: 16px;
}
.btnList{
  :deep(.el-button){
    margin-left: 0!important;
  }
}
</style>
