<template>
  <div>
    <layout>
      <layout-header>
        <div class="">
          <!--          按钮部分-->
          <el-form ref="elSearchFormRef"   class="demo-form-inline" :rules="searchRule" @keyup.enter="onSubmit">
            <el-form-item>
              <el-input v-model="searchInfo" placeholder="搜索" clearable style="width: 200px;margin: 5px"></el-input>
              <el-button type="primary" icon="search" @click="onSubmit" style="margin: 5px">查询</el-button>
			  <el-button type="primary"  @click="onAttendance" style="margin: 5px">新增</el-button>
              <el-button type="primary"  @click="baogong_del" style="margin: 5px;float: right;background-color: red">删除</el-button>
			   <el-button type="primary" @click="onxiaopiaoclick" style="margin: 5px">补打小票</el-button>
            </el-form-item>
          </el-form>
        </div>
      </layout-header>

      <layout>
        <!--左侧树侧形结构-->
        <layout-sider :resize-directions="['right']" :width="190" style="margin-right: 10px;">
          <div class="JKWTree-tree" style="height: 200px">
            <h3>总检报工</h3>
            <el-tree :data="treeData" class="treecolor"   @node-click="handleNodeClick"></el-tree>
          </div>
        </layout-sider>

        <!-- 右侧区域 -->
        <layout-content >
        <el-main>
          <div class="gva-table-box">
            <!-- 表格数据 -->
			<el-table ref="multipleTable" style="width: 100%;height: 65vh" tooltip-effect="dark"
				  :row-style="{ height: '20px' }"  :header-cell-style="{ padding: '0px' }"
				  :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
				  :data="tableData"  border row-key="ID"
				  size="small" 
				  highlight-current-row="true" @row-dblclick="updateCompanyFunc"
				  @row-click="tableRowClick" :show-overflow-tooltip="true"
				  @selection-change="handleSelectionChange">
				<el-table-column type="selection" width="55" />
				<el-table-column  sortable align="center" label="序号" prop="序号"  width="80" />
				<el-table-column  sortable align="left" label="订单子编号" prop="订单子编号"  width="120"/>
				<el-table-column  sortable  align="center" label="订单号" prop="订单号" width="120"/>
				<el-table-column  sortable  align="left" label="生产款号" prop="生产款号" width="120" />
				<el-table-column  sortable  align="left" label="款式" prop="款式" width="110" />
				<el-table-column  sortable  align="left" label="颜色" prop="颜色" width="80"  />
				<el-table-column  sortable  align="left" label="制单总数" prop="制单总数" width="100" />
				<el-table-column  sortable  align="left" label="组别" prop="组别" width="110" />
				<el-table-column  sortable  align="left" label="排产单数" prop="排产单数" width="110" />
				<el-table-column  sortable  align="left" label="尺码" prop="尺码" width="80" />
				<el-table-column  sortable  align="left" label="报工数量" prop="报工数量" width="110" />
				<el-table-column  sortable  align="left" label="是否尾包" prop="是否尾包" width="110" />
				<el-table-column  sortable  align="left" label="工序" prop="工序" width="80" />
				<el-table-column  sortable  align="left" label="验片人" prop="验片人" width="90" />
				<el-table-column  sortable  align="left" label="日期" prop="日期" width="120" />
			</el-table>
            <!-- 分页 -->
            <div class="gva-pagination">
              <el-pagination layout="total" :current-page="page" :page-size="pageSize"
               :total="total" @current-change="handleCurrentChange" @size-change="handleSizeChange" />
<!--              <el-pagination layout="total, sizes, prev, pager, next, jumper" :current-page="page" :page-size="pageSize" :page-sizes="[10, 30, 50, 100]"-->
<!--                             :total="total" @current-change="handleCurrentChange" @size-change="handleSizeChange" />-->
            </div>
          </div>

          <!-- 弹窗 -->
          <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" :title="'修改员工基本资料'" destroy-on-close>
            <el-form :model="formDataTest" label-position="right" ref="elFormRef" :rules="rule" label-width="100px">
              <div class="form-container">
                <!-- 左侧部分 -->
                <div class="form-column" style="width: 36%;">
                  <el-form-item label="员工编号：" prop="employeeId" class="mab" >
                    <el-input v-model="formDataTest['员工编号']"  placeholder="" style="width: 190px;"
                              id="员工编号" @keydown="handleKeyDown($event, '员工编号', '在职状态', '性别')" />
                  </el-form-item>
                  <el-form-item label="性别：" prop="gender" class="mab">
                    <el-input v-model="formDataTest['性别']"  placeholder="" style="width: 190px;"
                              id="性别" @keydown="handleKeyDown($event, '性别', '员工编号', '身份证号')" />
                  </el-form-item>
                  <el-form-item label="身份证号：" prop="gender" class="mab">
                    <el-input v-model="formDataTest['身份证号']"  placeholder="" style="width: 190px;"
                              id="身份证号"  @keydown="handleKeyDown($event, '身份证号', '性别', '所在部门')" />
                  </el-form-item>
                  <el-form-item label="部门名称：" prop="gender"  class="mab">
                    <el-input v-model="formDataTest['所在部门']"  placeholder="" style="width: 190px;"
                              id="所在部门" @keydown="handleKeyDown($event, '所在部门', '身份证号', '聘用日期')" />
                  </el-form-item>
                  <el-form-item label="入职日期:" prop="joinDate" class="mab">
                    <el-input v-model="formDataTest['聘用日期']"  placeholder="" style="width: 190px;"
                              id="聘用日期" @keydown="handleKeyDown($event, '聘用日期', '所在部门', '人员类别')" />
                  </el-form-item>
                  <el-form-item label="人员类别:" prop="joinDate" >
                    <el-select v-model="formDataTest['人员类别']" placeholder="" style="width: 190px;" id="人员类别"
                               @keydown="handleKeyDown($event, '人员类别', '聘用日期', '班次类型')"
                    >
                      <el-option label="生产" value="生产"></el-option>
                      <el-option label="行政" value="行政"></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="班次类型:" prop="joinDate" class="mab">
                    <el-input v-model="formDataTest['班次类型']"  placeholder="" style="width: 190px;"
                              id="班次类型" @keydown="handleKeyDown($event, '班次类型', '人员类别', '工资表类别')" />
                  </el-form-item>
                  <el-form-item label="工资表类别:" prop="joinDate" class="mab">
                    <el-select v-model="formDataTest['工资表类别']" placeholder="" style="width: 190px;"
                               id="工资表类别" @keydown="handleKeyDown($event, '工资表类别', '班次类型', 'U8在职')"
                    >
                      <el-option label="职员级计时工资表" value="职员级计时工资表"></el-option>
                      <el-option label="另发工资" value="另发工资"></el-option>
                      <el-option label="操作级计件工资表" value="操作级计件工资表"></el-option>
                      <el-option label="操作级计时工资表" value="操作级计时工资表"></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="U8在职:" prop="joinDate" class="mab">
                    <el-input v-model="formDataTest['U8在职']"   placeholder="" style="width: 190px;"
                              id="U8在职" @keydown="handleKeyDown($event, 'U8在职', '工资表类别', '员工姓名')" />
                  </el-form-item>
                </div>

                <!-- 中间部分 -->
                <div class="form-column">
                  <el-form-item label="员工姓名:" prop="name" class="mab" label-width="100">
                    <el-input v-model="formDataTest['员工姓名']"  placeholder="" style="width: 190px;"
                              id="员工姓名" @keydown="handleKeyDown($event, '员工姓名', 'U8在职', '出生日期')" />
                  </el-form-item>
                  <el-form-item label="出生日期:" prop="birthDate" class="mab" label-width="100">
                    <el-input v-model="formDataTest['出生日期']"  placeholder="" style="width: 190px;"
                              id="出生日期" @keydown="handleKeyDown($event, '出生日期', '员工姓名', '职称职务')" />
                  </el-form-item>
                  <el-form-item label="职务:" prop="position" class="mab" label-width="100">
                    <el-input v-model="formDataTest['职称职务']" placeholder="" style="width: 190px;"
                              id="职称职务" @keydown="handleKeyDown($event, '职称职务', '出生日期', '部门编码')" />
                  </el-form-item>
                  <el-form-item label="部门编号:" prop="position" class="mab" label-width="100">
                    <el-input v-model="formDataTest['部门编码']" placeholder="" style="width: 190px;"
                              id="部门编码" @keydown="handleKeyDown($event, '部门编码', '职称职务', '转正日期')" />
                  </el-form-item>
                  <el-form-item label="转正日期:" prop="departmentId" class="mab" label-width="100">
                    <el-input v-model="formDataTest['转正日期']" placeholder="" style="width: 190px;"
                              id="转正日期" @keydown="handleKeyDown($event, '转正日期', '部门编码', '扣减司龄')" />
                  </el-form-item>
                  <el-form-item label="扣减司龄:" prop="departmentId" class="mab" label-width="100">
                    <el-input v-model="formDataTest['扣减司龄']" placeholder="" style="width: 190px;"
                              id="扣减司龄" @keydown="handleKeyDown($event, '扣减司龄', '转正日期', '人员性质')" />
                  </el-form-item>
                  <el-form-item label="人员性质:" prop="departmentId" class="mab" label-width="100">
                    <el-select v-model="formDataTest['人员性质']" placeholder="" style="width: 190px;"
                               id="人员性质" @keydown="handleKeyDown($event, '人员性质', '扣减司龄', '薪酬核算分组')"
                    >
                      <el-option label="退休返聘" value="退休返聘"></el-option>
                      <el-option label="劳动合同工" value="劳动合同工"></el-option>
                      <el-option label="借用" value="借用"></el-option>
                      <el-option label="劳务派遣" value="劳务派遣"></el-option>
                      <el-option label="实习生" value="实习生"></el-option>
                    </el-select>
                  </el-form-item>
                  <el-form-item label="工资核算分组:" prop="joinDate" class="mab" label-width="100" >
                    <el-input v-model="formDataTest['薪酬核算分组']"  placeholder="" style="width: 190px;"
                              id="薪酬核算分组" @keydown="handleKeyDown($event, '薪酬核算分组', '人员性质', '在职状态')" />
                  </el-form-item>
                  <el-form-item label="在职状态:" prop="joinDate" class="mab" label-width="100"  >
                    <el-input v-model="formDataTest['在职状态']" placeholder="" style="width: 190px;"
                              id="在职状态" @keydown="handleKeyDown($event, '在职状态', '薪酬核算分组', '员工编号')" />
                  </el-form-item>
                </div>
              </div>
            </el-form>
            <!-- 添加编辑页面取消确定按钮 -->
              <div  style="text-align: right; ">
                <el-button @click="closeDialog">取消</el-button>
                <el-button type="primary"  @click="enterDialog">确定</el-button>
              </div>
          </el-dialog>

		 <!-- 新增弹窗 -->
		  <el-dialog v-model="AttendanceVisible" title="工序报工" destroy-on-close width="50%">
			  <el-row :gutter="24" style="margin-bottom: 20px;">
			      <el-form-item label="机台号:" prop="deliveryDate" class="mab" label-width="70">
					  <el-input v-model="add_formData['机台号']" style="width: 100px;" id="机台号" />
			      </el-form-item>
				  <el-form-item label="工序:" prop="deliveryDate" class="mab" label-width="70">
					  <el-input v-model="add_formData['工序']" style="width: 140px;" id="工序" />
				  </el-form-item>
				  <el-form-item label="组别:" prop="deliveryDate" class="mab" label-width="70">
					  <el-input v-model="add_formData['组别']" style="width: 140px;" id="组别" />
				  </el-form-item>
				  <el-form-item label="人员:" prop="deliveryDate" class="mab" label-width="70">
					  <el-input v-model="add_formData['人员']" style="width: 100px;" id="人员" />
				  </el-form-item>
			  </el-row>
			  
		      <el-row :gutter="24" style="margin-bottom: 20px;">
		          <el-input v-model="add_searchInfo" placeholder="扫描订单二维码获取订单信息" clearable style="width: 400px;margin: 5px"></el-input>
		          <el-button type="primary" icon="search" @click="add_onSubmit" style="margin: 5px">查询</el-button>
		      </el-row>
		      
		      <el-row :gutter="24" style="margin-bottom: 20px;">
		          <el-table ref="multipleTable" style="width: 100%;height: 20vh" tooltip-effect="dark"
		                    :row-style="{ height: '30px' }" :header-cell-style="{ padding: '0px' }"
		                    :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
		                    :data="add_tableData" border row-key="ID"
		                    size="small" highlight-current-row="true" @row-dblclick="add_updateCompanyFunc"
		                    @row-click="add_tableRowClick" :show-overflow-tooltip="true"
		                    @selection-change="handleSelectionChange">
		              <el-table-column sortable align="center" label="订单子编号" prop="订单子编号" width="180"/>
					  <el-table-column sortable align="center" label="订单号" prop="订单号" width="180"/>
		              <el-table-column sortable align="left" label="生产款号" prop="生产款号" width="305"/>
		              <el-table-column sortable align="left" label="款式" prop="款式" width="180"/>
		              <el-table-column sortable align="left" label="颜色" prop="颜色" width="180"/>
		          </el-table>
		      </el-row>
		      
			  <el-row :gutter="24" style="margin-bottom: 20px;">
				  <el-form-item label="尺码:" prop="joinDate" style="font-size: 30px;font-weight: 1000;" label-width="90px">
					<el-select v-model="add_formData['尺码']" style="width: 150px;" id="尺码">
					  <el-option label="是" value="32"></el-option>
					  <el-option label="否" value="33"></el-option>
					  <el-option label="否" value="34"></el-option>
					  <el-option label="否" value="35"></el-option>
					  <el-option label="否" value="36"></el-option>
					</el-select>
				</el-form-item>
				 <el-form-item label="数量:" prop="joinDate" style="font-size: 30px;font-weight: 1000;" label-width="130px">
					<el-input v-model="add_formData['数量']" style="width: 140px;height: 40px;" id="人员" />
				</el-form-item>
			  </el-row>
			  
			  <el-row :gutter="24" style="margin-bottom: 20px;">
				<el-form-item label="是否订单尾包:" prop="joinDate" style="font-size: 20px;font-weight: 1000;" label-width="145px">
					<el-select v-model="add_formData['是否订单尾包']" style="width: 150px;" id="尺码">
					  <el-option label="是" value="是"></el-option>
					  <el-option label="否" value="否"></el-option>
					</el-select>
				  </el-form-item>
			  </el-row>

		      
		      <template #footer>
		          <div class="dialog-footer">
		              <el-button @click="add_closeDialog">取消</el-button>
		              <el-button type="primary" @click="add_Dialog">保存</el-button>
					  <el-button type="primary" @click="add_printxp">打印小票</el-button>
		          </div>
		      </template>
		  </el-dialog>


        </el-main>
      </layout-content>
      </layout>
    </layout>
  </div>
</template>
<script>
export default {
  
};
</script>
<script setup>
// 全量引入格式化工具 请按需保留
import { Layout, LayoutSider, LayoutContent } from '@arco-design/web-vue';
import {hiprint} from "vue-plugin-hiprint";
import {ref, reactive,nextTick } from 'vue'
import {getCustom, getDepartment, getProductData,getStaffInfo, getStaffList, ygjbzledit,clockUpdate} from '@/api/yunyin/yunying'
import {ElMessage} from "element-plus";
defineOptions({name: 'Company'})

// =========== 获取左侧树侧形结构 ===========
const treeData = ref({})
const DataListdata = async () => {
  try {
    const data = 
    [{
      label : '总检完成记录',
      children : [
      {label : '2024.7.16'},
      {label : '2024.7.15'},
      {label : '2024.7.14'},
      {label : '2024.7.13'},
      {label : '2024.7.12'},
      {label : '2024.7.11'}
    ]
    }];
    treeData.value = data
  } catch (error) {
    console.error(error);
  }
};
DataListdata();

//点击左侧树形 获取右侧table列表
const tableData = reactive([]);
const _u8 = ref(null);  // U8系统的值
const _mes = ref(null); // MES系统的值
const handleNodeClick = async (node) => {
  _getStaffList();  // 执行获取员工列表的函数
};

//点击管理中心 显示部门的全部数据
const handleNodeExpand = async (node) => {
  // _department_code.value = node['编号'];
  searchInfo.value = '';
  _getStaffList()
}

// =========== 搜索 ===========
const searchInfo = ref('')
const _department_code = ref(null)
//点击【查询】按钮
const onSubmit = () => {
  _department_code.value = '';
  if(searchInfo.value === ''){
    tableData.length = 0;
  }else{
    _getStaffList();
  }
};

//获取员工信息列表
const _getStaffList = async ()=>{
	console.log(123)
    try {
		const WorkListdata = [
		    {
		      '序号':'1',
		      '订单子编号':'XXX001-1',
			  '订单号':'XXX001',
		      '生产款号':'2403-1622款',
		      '款式':'连衣裙',
		      '颜色':'红色',
			  '制单总数':'90',
			  '组别':'服装厂1组',
			  '排产单数':'50',
			  '尺码':'32',
			  '报工数量':'10',
			  '是否尾包':'否',
		      '工序':'仓库出库',
		      '上报人':'xxx',
		      '日期':'2024-07-16'
		    },
			{
			  '序号':'2',
			  '订单子编号':'XXX002-2',
			  '订单号':'XXX002',
			  '生产款号':'2403-1622款',
			  '款式':'西服',
			  '颜色':'白色',
			  '制单总数':'90',
			  '组别':'服装厂1组',
			  '排产单数':'60',
			  '尺码':'35',
			  '报工数量':'58',
			  '是否尾包':'否',
			  '工序':'仓库出库',
			  '上报人':'xxx',
			  '日期':'2024-07-16'
			},
			{
			  '序号':'3',
			  '订单子编号':'XXX003-3',
			  '订单号':'XXX003',
			  '生产款号':'2403-1622款',
			  '款式':'裤子',
			  '颜色':'黑色',
			  '制单总数':'90',
			  '组别':'服装厂1组',
			  '排产单数':'40',
			  '尺码':'36',
			  '报工数量':'37',
			  '是否尾包':'否',
			  '工序':'仓库出库',
			  '上报人':'xxx',
			  '日期':'2024-07-16'
			},
		    
		];
		console.log(WorkListdata)
		tableData.splice(0,tableData.length,...WorkListdata);//表格数据
		// total.value =WorkListdata.data.total;//共多少条
  } catch (error) {
    console.error(error);
  }
}

// =========== 新增按钮 ===========
const AttendanceVisible=ref(false)
const add_tableData = reactive([]);
// 获取当前日期
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 onAttendance = () => {
    AttendanceVisible.value=true
	const WorkListdata = [
	    {
		  '订单子编号':'XXX001-1',
	      '订单号':'XXX001',
	      '生产款号':'2403-1622款',
	      '款式':'连衣裙',
	      '颜色':'红色'
	    },
	];
	add_formData['机台号'] = '125'
	add_formData['工序'] = '车缝'
	add_formData['组别'] = '服装厂1组'
	add_formData['人员'] = 'xxx'
	
	add_formData['尺码'] = '31'
	add_formData['数量'] = '10'
	add_formData['是否订单尾包'] = '否'
	console.log(WorkListdata)
	add_tableData.splice(0,add_tableData.length,...WorkListdata);//表格数据
};
const add_formData = reactive({
  机台号: '',
  工序: '',
  组别: '',
  人员: '',
  尺码: '',
  数量: '',
  是否订单尾包: '',
});
// 新增确定
const add_Dialog = () => {
   
};
// 新增取消
const add_closeDialog = () => {
    AttendanceVisible.value=true
};

// =========== 新增搜索 ===========
const add_searchInfo = ref('')
//点击【查询】按钮
const add_onSubmit = async ()=>{
  if(add_searchInfo.value === '' || add_searchInfo.value === undefined){
    ElMessage({type: 'warning',message: '搜索内容不能为空' })
  }else{
	console.log(add_searchInfo.value)
  }
};



// 生成二维码的方法
const generateQRCode = () => {
  // 先清除之前的二维码，以免生成多个
  const qrcodeContainer = document.getElementById('qrcode');
  qrcodeContainer.innerHTML = '';

  // 生成新的二维码
  new QRCode(qrcodeContainer, {
    text: 'https://www.example.com', // 这里替换为你需要生成二维码的内容
    width: 100,
    height: 100,
  });
};

// =========== 删除按钮 ===========
const bgSelection = ref(null)
const baogong_del = () => {
	if(bgSelection.value === null || bgSelection.value === ''){
		  ElMessage({type: 'warning',message: '请选择删除的数据' })
	}else{
		 console.log(bgSelection.value)
	}
}
// 复选框
const handleSelectionChange = (selection, type) => {
  const ids = selection.map(item => {
    return item.订单子编号
  })
  bgSelection.value = ids.join(',')
}

// =========== 补打小票 ===========
const onxiaopiaoclick = async (row) => {
	
}
// =========== 修改 ===========
// 双击修改
const updateCompanyFunc = async (row) => {
  // let code = row['员工编号'];
  // const getStaffInfo_data = await getStaffInfo({code:code});
  // formDataTest.value = getStaffInfo_data.data;
  // dialogFormVisible.value = true;
};

// =========== 分页 ===========
// 分页相关的响应式变量
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();
};

// 弹窗控制标记
const dialogFormVisible = ref(false)
//修改
const formDataTest = ref({})

// 修改关闭弹窗
const closeDialog = () => {dialogFormVisible.value = false,AttendanceVisible.value=false}

// 弹窗确定
const enterDialog = async () => {
	
}
//修改
const _ygjbzledit = async ()=>{
  // const formattedData = {
  //   '员工编号': formDataTest.value['员工编号'],
  //   '员工姓名': formDataTest.value['员工姓名'],
  //   '性别': formDataTest.value['性别'],
  //   '出生日期': formDataTest.value['出生日期'],
  //   '身份证号': formDataTest.value['身份证号'],
  //   '职称职务': formDataTest.value['职称职务'],
  //   '所在部门': formDataTest.value['所在部门'],
  //   '聘用日期': formDataTest.value['聘用日期'],
  //   '转正日期': formDataTest.value['转正日期'],
  //   '扣减司龄': formDataTest.value['扣减司龄'] ? formDataTest.value['扣减司龄'] : '0',
  //   '人员类别': formDataTest.value['人员类别'],
  //   '人员性质': formDataTest.value['人员性质'],
  //   '班次类型': formDataTest.value['班次类型'],
  //   '薪酬核算分组': formDataTest.value['薪酬核算分组'],
  //   '工资表类别': formDataTest.value['工资表类别'],
  //   'U8在职': formDataTest.value['U8在职'],
  //   '在职状态': formDataTest.value['在职状态'],
  //   '部门编码': formDataTest.value['部门编码'],
  // };
  // try {
  //   const ygjbzledit_eddt = await ygjbzledit(formattedData);
  //   if (ygjbzledit_eddt .code === 0) {
  //     dialogFormVisible.value = false;
  //     ElMessage({type: 'success',message: '更新成功'})
  //   } else {
  //     console.log(ygjbzledit_eddt);
  //     ElMessage({ type: 'error',message: '更新失败'})
  //   }
  // } catch (error) {
  //   console.error(error);
  // }
}

// =========== 打印小票 ===========
const jsondata = {"panels":[{"index":0,"name":1,"height":296.6,"width":210,"paperHeader":328.5,"paperFooter":832.5,"printElements":[{"options":{"left":207.5,"top":335,"height":61.5,"width":211.5,"title":"这是更新后的元素","right":418.9921875,"bottom":397.2421875,"vCenter":313.2421875,"hCenter":366.4921875,"field":"zddbh","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":40,"textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":0,"top":337.5,"height":60,"width":207,"title":"子订单编号","coordinateSync":false,"widthHeightSync":false,"fontSize":40,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":187.74375915527344,"bottom":392.25,"vCenter":84.24375915527344,"hCenter":360.75},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":432.5,"top":380,"height":159,"width":159,"title":"二维码","qrcodeType":"qrcode","testData":"qrcode","right":590.7421875,"bottom":538.2421875,"vCenter":511.2421875,"hCenter":458.7421875,"field":"emm","qrCodeLevel":0,"coordinateSync":false,"widthHeightSync":false,"hideTitle":true},"printElementType":{"title":"二维码","type":"qrcode"}},{"options":{"left":85,"top":400,"height":61.5,"width":337.5,"title":"这是更新后的元素","right":297,"bottom":463.5,"vCenter":191.25,"hCenter":432.75,"field":"kh","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":40,"textContentVerticalAlign":"middle","qrCodeLevel":0,"qid":"zddbh_1"},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":0,"top":400,"height":60,"width":84,"title":"款号","coordinateSync":false,"widthHeightSync":false,"fontSize":40,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":209.49375915527344,"bottom":455.4937505722046,"vCenter":105.99375915527344,"hCenter":423.9937505722046},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":0,"top":460,"height":60,"width":84,"title":"品名","coordinateSync":false,"widthHeightSync":false,"fontSize":40,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":207.75,"bottom":522.4921875,"vCenter":104.25,"hCenter":492.4921875},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":85,"top":462.5,"height":61.5,"width":342,"title":"这是更新后的元素","right":295.2421875,"bottom":523.9921875,"vCenter":189.4921875,"hCenter":493.2421875,"field":"pm","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":40,"textContentVerticalAlign":"middle","qrCodeLevel":0,"qid":"kh_1"},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":85,"top":525,"height":61.5,"width":211.5,"title":"这是更新后的元素","right":293.7421875,"bottom":585.4921875,"vCenter":187.9921875,"hCenter":554.7421875,"field":"ys","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":40,"textContentVerticalAlign":"middle","qrCodeLevel":0,"qid":"kh_2"},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":0,"top":525,"height":60,"width":84,"title":"颜色","coordinateSync":false,"widthHeightSync":false,"fontSize":40,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":209.49375915527344,"bottom":580.5,"vCenter":105.99375915527344,"hCenter":549},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":0,"top":587.5,"height":60,"width":82.5,"title":"尺码","coordinateSync":false,"widthHeightSync":false,"fontSize":40,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":209.49375915527344,"bottom":642.9937591552734,"vCenter":105.99375915527344,"hCenter":611.4937591552734},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":85,"top":590,"height":61.5,"width":211.5,"title":"这是更新后的元素","right":295.9921875,"bottom":651.24609375,"vCenter":190.2421875,"hCenter":620.49609375,"field":"cm","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":40,"textContentVerticalAlign":"middle","qrCodeLevel":0,"qid":"kh_3"},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":0,"top":650,"height":60,"width":82.5,"title":"数量","coordinateSync":false,"widthHeightSync":false,"fontSize":40,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":209.49375915527344,"bottom":705.4968795776367,"vCenter":105.99375915527344,"hCenter":673.9968795776367},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":85,"top":652.5,"height":61.5,"width":211.5,"title":"这是更新后的元素","right":298.2421875,"bottom":714,"vCenter":192.4921875,"hCenter":683.25,"field":"sl","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":40,"textContentVerticalAlign":"middle","qrCodeLevel":0,"qid":"kh_4"},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":450,"top":705,"height":61.5,"width":120,"title":"这是更新后的元素","right":570.9937362670898,"bottom":765.75,"vCenter":510.99373626708984,"hCenter":735,"field":"wb","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":40,"textContentVerticalAlign":"middle","qrCodeLevel":0,"qid":"kh_7"},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":362.5,"top":707.5,"height":60,"width":87,"title":"尾包","coordinateSync":false,"widthHeightSync":false,"fontSize":40,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":450.24373626708984,"bottom":765.4968795776367,"vCenter":406.74373626708984,"hCenter":735.4968795776367},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":85,"top":710,"height":61.5,"width":276,"title":"这是更新后的元素","right":298.2421875,"bottom":771.99609375,"vCenter":192.4921875,"hCenter":741.24609375,"field":"zb","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":40,"textContentVerticalAlign":"middle","qrCodeLevel":0,"qid":"kh_5"},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":0,"top":712.5,"height":60,"width":82.5,"title":"组别","coordinateSync":false,"widthHeightSync":false,"fontSize":40,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":209.49375915527344,"bottom":768,"vCenter":105.99375915527344,"hCenter":736.5},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":0,"top":765,"height":60,"width":168,"title":"打印日期","coordinateSync":false,"widthHeightSync":false,"fontSize":40,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":215.74687957763672,"bottom":814.7437648773193,"vCenter":112.24687957763672,"hCenter":783.2437648773193},"printElementType":{"title":"这是更新后的元素","type":"text"}},{"options":{"left":170,"top":767.5,"height":61.5,"width":420,"title":"这是更新后的元素","right":381,"bottom":828.75,"vCenter":275.25,"hCenter":798,"field":"dyrq","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":40,"textContentVerticalAlign":"middle","qrCodeLevel":0,"qid":"kh_6"},"printElementType":{"title":"这是更新后的元素","type":"text"}}],"paperNumberLeft":568.5,"paperNumberTop":330,"paperNumberContinue":true,"watermarkOptions":{"content":"vue-plugin-hiprint","rotate":25,"timestamp":true,"format":"YYYY-MM-DD HH:mm"},"panelLayoutOptions":{}}]}

// 打印小票按钮点击时直接触发打印
const add_printxp = () => {
  hiprint.init()
  const hiprintTemplate = new hiprint.PrintTemplate({ template: jsondata })

  // 获取当前日期
  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 printdata  = {
    "emm": "子订单编号",
	"zddbh": "123",
	"kh": "123",
	"pm": "123",
	"ys": add_formData['颜色'],
	"cm": add_formData['尺码'],
	"sl": add_formData['数量'],
	"zb": add_formData['组别'],
	"dyrq": currentDate,
	"wb": add_formData['是否订单尾包'],
  }
  hiprintTemplate.print(printdata);
};

</script>
<style scoped>
.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;
  }
}
/*:deep(.el-table td .cell) {*/
/*  line-height: 30px !important;*/
/*}*/
.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;
}
/* 图片上传 */
.upload-box {
  width: 200px;
  height: 200px;
  border: 2px dashed #e2e2e2;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  cursor: pointer;
}
.uploaded-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.upload-icon {
  font-size: 40px;
  color: #c0c4cc;
}
.file-input {
  display: none;
}
.el-table .warning-row {
  background: oldlace;
}

/* 选中某行时的背景色 */
: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;
}
.mab{
  margin-bottom: 5px;
}

</style>
