<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 #status>
					<div>未发货</div>
				</template>
        <template #menu="{row}">
					<el-button type="text" icon="el-icon-pie-chart" @click="toPurchaseDetails(row)">查看</el-button>
				</template>
			</avue-crud>
		</el-card>
	</div>
</template>

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

})
// 定义变量内容
JSON.stringify()
const state = reactive({
	page: {
		total: 1000,
		currentPage: 1,
		pageSize: 10,
	},
	option: {
		index: false,
		menuWidth: 120,
		border: true,
		delBtn: false,
		editBtn: false,
		align: 'center',
    // searchLabelWidth:100,
    selection: true,
    searchMenuSpan:3,
    addBtn:false,
		column: [
			{ label: computed(() => t('message.list.PONumber')), prop: 'fBillNo', width: 150,search: true,searchSpan: 3 },
      { label: computed(() => t('message.list.PurchaseDate')), prop: 'fDate', width: 150,search: true,type: 'datetime', searchSpan: 6,searchRange: true,},
      { label: '关闭状态', prop: 'hangzhuangtai', width: 150 },
      { label: '物料编码', prop: 'wuliaobinama', width: 150 },
      { label: '物料名称', prop: 'wuliaomingcheng', width: 150 },
      { label: '采购单位', prop: 'caigoudanwei', width: 150 },
      { label: '采购数量', prop: 'caigoushuliang', width: 150 },
      { label: '交货日期', prop: 'jioahuiriqi', width: 150 },
      { label: '业务状态', prop: 'yewuzhuangtai', width: 150,search: true,searchSpan: 3 },
      { label: '累计收料数量', prop: 'ljslsl', width: 150 },
      { label: '剩余收料数量', prop: 'syslsl', width: 150 },
      { label: '供应商承诺交期', prop: 'gyscnjq', width: 150 },
      { label: '供应商承诺最新交期', prop: 'gyscnzxjq', width: 150 },
		],
	},
	data: [],
  formData:{}
});

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){}
}
const resetChange = () => {
  
}
const toPurchaseDetails = (item:any) => {
  router.push({
    path: '/purchaseDetails',
    query:{
      topId:item.fiD
    }
  })
}
const getList = () => {
  listApi().getPageList({
    ...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>
:deep(.el-table__cell){
  padding: 0 !important;
}
.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;
}
</style>
