<template>
  <div>
    <layout>
		<h1 style="margin: 0%;margin-bottom: 6px;">选择日期查询当月面料库存汇总</h1>
		<el-row :gutter="24" style="margin-bottom: 6px;">
			  <!-- <el-input v-model="add_searchInfo" placeholder="请扫描订单编号或输入生产款号模糊查询"  @input="handleInput"
				@keyup.enter="add_onSubmit" id="searchInput"  style="width: 340px;height: 50px;margin-left: 10px;">
			  </el-input> -->
        
        <el-date-picker
              v-model="mlscgdformData['日期']" id="日期"  @input="handleInput"
              style="height: 50px;margin-left: 20px;"
              type="date"/>
			  <el-button type="primary" @click="add_onSubmit" style="height: 50px;font-size: 20px;">查询</el-button>
			  <!-- <el-button type="primary" icon="reading" @click="details_onSubmit" style="height: 50px;font-size: 20px;">出库退还记录</el-button> -->
		</el-row>
      <layout>
		  
        <layout-content >
          <div class="gva-table-box">
           <el-table ref="multipleTable" style="width: 100%;height: 64vh" tooltip-effect="dark"
                      :row-style="{ height: '40px' }"  :header-cell-style="{ padding: '0px' }"
                      :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
                      :data="restableData"  border row-key="ID" size="small"  
					  :cell-class-name="tableDataCellClass"
                      highlight-current-row="true"  @row-dblclick="updateCompanyFunc"
                      @row-click="tableRowClick" :show-overflow-tooltip="true"
                      @selection-change="handleSelectionChange">
			        <!-- <el-table-column type="selection" width="80" /> -->
              <el-table-column  align="left" label="订单编号" prop="订单编号" width="105" />
			  <el-table-column  align="left" label="客户编号" prop="客户编号" width="80"/>
              <el-table-column  align="left" label="生产款号" prop="生产款号" width="170"/>
              <el-table-column  align="left" label="款式" 	 prop="款式" 	width="170"/>
			  <el-table-column  align="left" label="物料名称" prop="物料名称" width="160"/>
              <el-table-column  align="left" label="库存总量" prop="库存总量" width="100"/>
			  <el-table-column  align="left" label="面料结余" prop="面料结余" width="100"/>
			  <el-table-column  align="left" label="投料单位" prop="投料单位" width="100"/>
            </el-table>
            <div class="dialog-footer" style="text-align: left;margin-right: 60px;">
			</div>
          </div>
      </layout-content>
      </layout>
    </layout>
  </div>

  
</template>
<script>
//点击按钮显示下方表格
export default {
  data() {
    return {
      currentTable: '', // 当前展示的表格
      activeName: 'first',
      _ddhval:'',
	  add_gddialogFormVisible: true,
    };
  },
  methods: {
    
  }
};
</script>
<script setup>
// 全量引入格式化工具 请按需保留
import { Layout, LayoutSider, LayoutContent } from '@arco-design/web-vue';
import {ref, reactive} from 'vue'
import {getSpotList,getSpotTab,orderSearch,outReport,orderBomList,FabricDetail,fabricList} from '@/api/mes/job'
import {ElMessage} from "element-plus";
// import { get } from 'scriptjs';
defineOptions({name: 'Company'})
import { useUserStore } from '@/pinia/modules/user'
//获取用户登录信息
const userStore = useUserStore()
const _username = ref('')
_username.value = userStore.userInfo.userName + '/' + userStore.userInfo.nickName
console.log('获取用户名称',_username.value)
//全局调用获取当前日期
const today = new Date();
const year = today.getFullYear();
const month = String(today.getMonth() + 1).padStart(2, '0'); // 月份从 0 开始，需要补零
const day = String(today.getDate()).padStart(2, '0');
const hours = String(today.getHours()).padStart(2, '0');
const minutes = String(today.getMinutes()).padStart(2, '0');
const seconds = String(today.getSeconds()).padStart(2, '0');
const currentDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
const currentDates = `${year}-${month}-${day}`;
const currentDatess = `${year}-${month}`;


const mlscgdformData = reactive({
  日期: '',
});

//自动聚焦光标input
const getMachineMacdata = async () => {
  mlscgdformData['日期'] = currentDates
  restableData.splice(0, restableData.length);//清空表格
  
	setTimeout(() => {
		const inputElement = document.getElementById('searchInput');
		if (inputElement) {
			inputElement.focus();		
		}
	}, 100); // 延迟100毫秒
}
getMachineMacdata();


const fabricListdada = async () => {

	//订单信息数据查询【接口】
	const fabricListdata = await fabricList({mouth:currentDates});
  console.log(fabricListdata)
	restableData.splice(0,fabricListdata.length,...fabricListdata.data);
}
fabricListdada()
//全局调用参数
const add_searchInfo = ref('')//搜索
const restableData = reactive([])//表格
const _orderid = ref('')//订单子编号
const handleInput = async ()=>{
	add_onSubmit()
}

//查询按钮
const add_onSubmit = async ()=>{
	restableData.splice(0, restableData.length);//清空表格
  //日期转换
  let lhrq_formattedDeliveryDate = '';  
  if (mlscgdformData['日期']) {  
    const date = new Date(mlscgdformData['日期']);  
    lhrq_formattedDeliveryDate = `${date.getFullYear()}-${('0' + (date.getMonth() + 1)).slice(-2)}-${('0' + date.getDate()).slice(-2)}`;  
  }  

	//订单信息数据查询【接口】
	const fabricListdata = await fabricList({mouth:lhrq_formattedDeliveryDate});
  console.log(fabricListdata)
	restableData.splice(0,fabricListdata.length,...fabricListdata.data);
};

//表格行点击
const tableRowClick = async (row)=>{
	console.log(row)
}

const resbomtableData = ref([]);



// =========== 分页 ===========
// 分页相关的响应式变量
const page = ref(1)
const total = ref(0)
const pageSize = ref(10)
// 分页
const handleCurrentChange = (val) => {
  page.value = val;
  _getStaffList();
};

// 修改页面容量 点击多少条/页
const handleSizeChange = (val) => {
  page.value = 10;//默认显示
  pageSize.value = val;
  _getStaffList();
};
</script>
<style scoped>
/* 根据出库状态文字颜色 */
:deep(.status-plan-usage-low div) {
  color: #8c939d  !important;
}
:deep(.statusy-plan-usage-low div) {
  color: blue !important;
}
.form-container {
  display: flex;
  flex-wrap: wrap;
}
.form-column {
  /*flex: 1;*/
  margin-right: 15px; /* 调整列之间的间距 */
}
/* 左侧输入框宽度调整 */
.form-column .el-form-item .el-input {
  width: 150px; /* 调整左侧输入框的宽度 */
}
/* 媒体查询，根据需要调整断点 */
@media screen and (max-width: 768px) {
  .form-column {
    flex: 1 0 100%; /* 在小屏幕下变成单列布局 */
    margin-right: 0;
  }
}
.JKWTree-container {
  display: flex;
}
.JKWTree-tree {
  /*width: 300px;*/
  background-color: #fff;
  padding: 10px;
  margin-right: 20px;
}
.JKWTree-tree h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 10px 0;
}
.JKWTree-content {
  flex: 1;
}
/* 表格复选框大小调整 */
:deep(.el-checkbox.el-checkbox--small .el-checkbox__inner) {
    width: 45px; /* 复选框宽度 */
    height: 23px; /* 复选框高度 */
}
/*bom参数背景*/
:deep(.el-table__body .background-plan-usage-low div div div) {
  background: #80FA80 !important;
}
/* 选中某行时的背景色 */
:deep(.el-table__body tr.current-row) > td {
  background: #ff80ff !important;
}
:deep(.el-checkbox.el-checkbox--small.is-checked .el-checkbox__inner::after) {
    transform: scale(1.2) rotate(45deg); /* 调整选中后的对勾大小 */
    top: 5%; /* 调整对勾位置 */
    left: 40%; /* 调整对勾位置 */
    width: 5px; /* 调整对勾宽度 */
    height: 9px; /* 调整对勾高度 */
}
/* 选中某行时的背景色 */
:deep(.el-table__body tr.current-row) > td {
  background: #ff80ff !important;
}
</style>
<style scoped>
:deep(.el-table td .cell) {
  line-height: 20px !important;
}
:deep(.el-tabs__header){
  margin-bottom: 0;
}
.search{
  margin-left: 0px !important;
  margin-right: 10px !important;
}
.bt{
  margin-left: 2px !important;
  padding: 3px !important;
  font-size: 12px;
}
.el-tabs__header{
  margin: 0px !important;
}
.gva-table-box{
  padding: 0px !important;
	margin-left: 5px !important;
}
.mab{
  margin-bottom: 5px;
}
/* 搜索样式 */
::v-deep .el-input__wrapper #searchInput {  
  font-size: 16px; 
}  
::v-deep(.el-descriptions__table tbody tr .is-bordered-label){
	width: 60px;
}
::v-deep(.el-descriptions__table tbody tr .el-descriptions__content){
	width: 120px;
}
</style>
