<template>
	<el-container v-if="visible">
		<el-header v-if="descriptionVisible">
			<div style="display: flex;align-items: center;justify-content: space-between;width: 100%;">
				<div>检验人:{{setForm.test_user_name}}</div>
				<div>检验设备:{{setForm.equipment_name}}</div>
				<div>缺陷项:
					<span v-for="(item1,index1) in defectlists" :key="item1.id">{{ item1.defect_name }} 
						<span v-if="index1 < defectlists.length-1">、</span>
					</span>
				</div>
				<div>检测项:
					<span v-for="(item2,index2) in testitemlists" :key="item2.id">{{ item2.testitem_name }}
						<span v-if="index2 < testitemlists.length-1">、</span>
					</span>
				</div>
			</div>
		</el-header>
		<el-main id="mlogbwMain">
			<div style="margin-top: -5px;margin-bottom: 5px;position: relative;">
				<el-button type="primary" v-if="!isSubmit" @click="check_add">新增</el-button>
				<el-button type="primary" v-if="!isSubmit&&processType=='20'" @click="check_start">检验</el-button>
				<el-button type="primary" v-if="multipleSet" @click="check_set" style="position: absolute;left: 210px;">批量操作</el-button>
				<el-input v-if="multipleSet" v-model="wprInputText"  @change="wprinputChange" style="width:200px;position: absolute;left: 308px;"></el-input>
				<el-button v-if="!isSubmit" type="success" @click="digital ">数字识别</el-button>
				<div style="width:fit-content;position: absolute;right: 0;display: inline-block;">
					<div style="display: flex;align-items: center;gap: 8px;">
						<el-link v-if="test_file!==''" :href="test_file" target="_blank">{{ test_file_name }}</el-linK>
						<scFileImport
							v-if="project_code=='tcerp'&&processType=='20'&&!isSubmit"
							:name = "'上传检验附件'"
							accept=".xlsx"
							:apiObj="$API.common.upload"
							@success="upSuccess"
						></scFileImport><!-- :templateUrl="checkTemplate" -->
					</div>
				</div>
				<div v-if="columnSettingVisible" class="col-setting-float-panel" @click.stop>
					<div v-for="col in allColumnOptions" :key="col.key" class="col-setting-item">
						<el-checkbox
							:model-value="isColVisible(col.key)"
							@change="toggleColumn(col.key)"
						>{{ col.label }}</el-checkbox>
					</div>
				</div>
			</div>
			<div class="table-scroll">
				<table id="mlogbwlist" class="tables">
					<thead>
						<tr>
							<th class="w_50 sticky-cell sticky-left-select" style="padding: 5px;">
							<input type="checkbox" class="checkboxInput" v-model="selectedAll" :value="selectedAll"  @change="selectAllChange">
						</th>
							<th class="w_50 sticky-cell sticky-left-index">序号</th>
							<th class="w_140 sticky-cell sticky-left-batch">物料批次</th>
							<th class="w_140 sticky-cell sticky-left-number">物料编号</th>
							<th class="w_150" v-if="route_code=='niuzhuan'" v-show="isColVisible('equip')">生产设备</th>
							<th class="w_180" v-if="route_code=='niuzhuan'" v-show="isColVisible('time')">扭转日期</th>
							<th class="w_150" v-if="mgroupName=='喷码'" v-show="isColVisible('tooling')">工装</th>
							<th class="w_80" v-for="item in qct_testitems" :key="item.id" v-show="isColVisible('testitem_'+item.id)">{{ item.testitem_name }}</th>
							<th class="w_80" v-for="item in qct_defects" :key="item.id" v-show="isColVisible('defect_'+item.id)">{{ item.defect_name }}</th>
							<th class="w_80" v-show="isColVisible('note')">备注</th>
							<th class="w_150 sticky-cell sticky-right-action" v-if="!isSubmit">操作</th>
						</tr>
					</thead>
					<tbody>
						<tr v-for="(row, index) in mlogbwlist" :key="row.id">
							<td class="w_50 padding_4 sticky-cell sticky-left-select">
							<input type="checkbox" class="checkboxInput" v-model="selectedindexes" :value="row.id" @change="selectChange">
						</td>
							<td class="w_50 padding_4 sticky-cell sticky-left-index">
							{{ index + 1 }}
						</td>
							<td class="w_140 sticky-cell sticky-left-batch">
							<input v-if="row.isEdit" v-model="row.mlogb__batch" placeholder="物料批次">
							<span v-else>{{ row.mlogb__batch }}</span>
						</td>
							<td class="w_140 sticky-cell sticky-left-number">
							<input v-if="row.isEdit" v-model="row.number" placeholder="物料编号">
							<span v-else>{{ row.number }}</span>
							<span v-if="row.wpr_number_out !== null && row.wpr_number_out !== undefined">——{{ row.wpr_number_out }}</span>
						</td>
							<td class="w_150 " v-if="route_code=='niuzhuan'" v-show="isColVisible('equip')">
							<select name="pets" id="pet-select" v-if="row.isEdit" style="width: 100%;" v-model="row.equip" :value="row.equip">
								<option v-for="item in optionsEq" :key="item.id" :value="item.id">
									{{ item.number }}
								</option>
							</select>
							<span v-else>{{ row.equip_name }}<span v-if="row.equip_number&&row.equip_number!=null">{{ row.equip_number }}</span></span>
						</td>
							<td class="w_180 " v-if="route_code=='niuzhuan'" v-show="isColVisible('time')">
							<input v-if="row.isEdit" type="datetime-local" id="datetime" v-model="row.work_start_time" @change = "timeChange(row)">
							<div v-else>
								<span v-if="row.work_start_time!==null">{{ row.work_start_time}}</span>
							</div>
						</td>
						<td class="w_150 " v-if="mgroupName=='喷码'" v-show="isColVisible('tooling')">
							<select name="tooling" id="tooling-select" v-if="row.isEdit" style="width: 100%;" v-model="row.tooling" :value="row.tooling">
								<option v-for="item in optionsTooling" :key="item.id" :value="item.id">
									{{ item.name }}
								</option>
							</select>
							<span v-else>{{ getToolingName(row.wpr_pre_info?.tooling) || row.tooling_name }}</span>
						</td>
							<td class="w_80 " v-for="item in qct_testitems" :key="item.id" v-show="isColVisible('testitem_'+item.id)">
							<span v-if="!row.isEdit || !item.canEdit">{{ row[item.testitem_name] }}</span>
							<input v-if="item.testitem_field_type == 'input-number' && row.isEdit && item.canEdit"
								type="number" v-model="row[item.testitem_name]" @change="defectCountSun(row)">
								<input v-if="item.testitem_field_type == 'input-int' && row.isEdit && item.canEdit"
								type="number" v-model="row[item.testitem_name]" @change="defectCountSun(row)">
							<input v-if="item.testitem_field_type == 'input-text' && row.isEdit && item.canEdit"
								type="text" v-model="row[item.testitem_name]" @change="defectCountSun(row)">
							<select v-if="item.testitem_field_type == 'select-text' && row.isEdit && item.canEdit"
									v-model="row[item.testitem_name]" @change="defectCountSun(row)">
								<option v-for="item0 in item.testitem_choices" :key="item0" :value="item0">{{ item0 }}</option>
							</select>
							<select v-if="item.testitem_field_type == 'selects-text' && row.isEdit && item.canEdit"
									v-model="row[item.testitem_name]" @change="defectCountSun(row)">
								<option v-for="item0 in item.testitem_choices" :key="item0" :value="item0">{{ item0 }}</option>
							</select>
						</td>
							<td class="w_80  padding_4 defectBlock" v-for="item in qct_defects" :key="item.id" v-show="isColVisible('defect_'+item.id)">
							<input type="checkbox" class="checkboxInput" :disabled="!row.isEdit || !item.canEdit" v-model="row[item.defect_name]" @change="switchChange(row, item,index)">
						</td>
							<td class="w_80 " v-show="isColVisible('note')">
							<input v-if="row.isEdit" v-model="row.note" placeholder="备注">
							<span v-else style="width: 100%;height: 100%;display: inline-block;">{{ row.note }}</span>
						</td>
							<td
								class="w_150 sticky-cell sticky-right-action operation-cell"
								:class="{ 'is-menu-open': openedActionMenu === actionMenuKey(row, index) }"
								v-if="!isSubmit"
							>
							<button v-if="row.isEdit" type="button" class="btn btn_green" @click="formTableSave(row,index)">保存</button>
							<button v-if="row.isEdit && row.id" type="button" class="btn btn_red" @click="formTableCancel(row,index)">取消</button>
							<button v-if="row.isEdit && setForm.cd_req_addr !== null" type="button" class="btn btn_yellow" @click="getEqData(index)">重取数据</button>
							<button v-if="!row.isEdit" type="button" class="btn btn_blue" @click="formTableEdit(index)">编辑</button>
							<div class="action-more" v-if="(row.isEdit && !row.id) || !row.isEdit">
								<button
									type="button"
									class="more-trigger"
									aria-label="更多操作"
									@click.stop="toggleActionMenu(actionMenuKey(row, index))"
								>
									<span></span>
									<span></span>
									<span></span>
								</button>
								<div
									v-show="openedActionMenu === actionMenuKey(row, index)"
									class="more-menu"
									@click.stop
								>
									<button v-if="row.isEdit && !row.id" type="button" class="more-menu-btn" @click="formTableDelet(row, index)">删除</button>
									<button v-if="!row.isEdit" type="button" class="more-menu-btn" @click="formTableDel(row.id,index)">删除</button>
								</div>
							</div>
						</td>
						</tr>
					</tbody>
				</table>
			</div>
		</el-main>
	</el-container>
	<el-dialog
		title="检验"
		v-model="checkVisible"
		destroy-on-close
	>
		<el-container>
			<el-main>
				<el-form
					ref="dialogForm"
					:model="form"
					:rules="rules"
					label-width="80px"
				>
					<el-row>
						<el-col :md="12" :sm="12" :xs="24">
							<el-form-item label="操作人" prop="test_user">
								<ehsSelect
									v-model="form.test_user"
									:showName="test_user_name"
									:apiObj="this.$API.system.user.list"
									:params="{ depts: dept }"
									style="width: 100%"
									@change="userChange"
								></ehsSelect>
							</el-form-item>
						</el-col>
						<el-col :md="12" :sm="12" :xs="24">
							<el-form-item label="设备">
								<el-select
									v-model="form.equipment"
									placeholder="设备"
									clearable
									filterable
									style="width: 100%"
									@change="equipmentChange"
								>
									<el-option
										v-for="item in equipmentOptions"
										:key="item.id"
										:label="item.name"
										:value="item.id"
									>
										<span style="float:left">{{item.name}}</span>
										<span style="float:right">{{item.number}}</span>
									</el-option>
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :md="12" :sm="12" :xs="24">
							<el-form-item label="检测项">
								<el-select
									v-model="form.testitemids"
									placeholder="检测项"
									clearable
									filterable
									multiple
									style="width: 100%"
									@change="testitemidsChange"
								>
									<el-option
										v-for="item in qct_testitems"
										:key="item.testitem"
										:label="item.testitem_name"
										:value="item.testitem"
									></el-option>
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :md="12" :sm="12" :xs="24">
							<el-form-item label="缺陷项">
								<el-select
									v-model="form.defectids"
									placeholder="缺陷项"
									clearable
									filterable
									multiple
									style="width: 100%"
									@change="defectidsChange"
								>
									<template #header>
										<el-checkbox
											v-model="checkAll"
											@change="handleCheckAll"
										>全部</el-checkbox>
									</template>
									<el-option
										v-for="item in qct_defects"
										:key="item.defect"
										:label="item.defect_name"
										:value="item.defect"
									></el-option>
								</el-select>
							</el-form-item>
						</el-col>
					</el-row>
				</el-form>
				<el-footer>
					<el-button type="primary" v-loading="isSaveing" @click.stop="checkSetting" save>确定</el-button>
					<el-button @click="saveCancel">取消</el-button>
				</el-footer>
			</el-main>
		</el-container>
	</el-dialog>
	<el-dialog
		title="批量检验"
		v-model="setVisible"
		destroy-on-close
		style="height:100%;width:80%"
	>
		<el-container>
			<el-main>
				<el-form
					ref="dialogForm"
					:model="form"
					:rules="rules"
					label-width="150px"
				>
					<el-row>
						<el-col v-for="item2 in defectlists" :key="item2.id" :span="12">
							<el-form-item :label="item2.defect_name">
								<el-switch v-model="item2.value" @change="defect_change(item2)"></el-switch>
							</el-form-item>
						</el-col>
						<el-col>
							<!-- 扫描物料的number 根据number对比list里的物料-->
							<el-form-item label="检测物料" label-width="70px">
								<el-input v-model="wprNumber" @change="wprChange(wprNumber)"></el-input>
							</el-form-item>
						</el-col>
					</el-row>
				</el-form>
				<el-row>
					<el-table :data="selectWprList" border>
						<el-table-column type="index"></el-table-column>
						<el-table-column prop="number" label="物料编号"></el-table-column>
						<el-table-column v-for="item2 in defectlists" :key="item2.id" :label="item2.defect_name">
							<template #default="scope">
								<el-switch  v-model="scope.row[item2.defect_name]" disabled></el-switch>
							</template>
						</el-table-column>
						<el-table-column label="操作" width="90" align="center" fixed="right">
							<template #default="scope">
								<el-button type="danger" size="small" @click="selectWprDel(scope.row)">删除</el-button>
							</template>
						</el-table-column>
					</el-table>
				</el-row>
				<el-footer>
					<el-button type="primary" :loading="isSaveing" @click.stop="saveSetting" save>保存</el-button>
					<el-button @click="saveSettingCancel">取消</el-button>
				</el-footer>
			</el-main>
		</el-container>
	</el-dialog>
</template>
<script>
import { ElLoading } from "element-plus";
import scFileImport from "@/components/scFileImport";
export default {
	components: {scFileImport},
	props: {
		qct: {
			type: String,
			default: "",
		},
		mlogId: {
			type: String,
			default: "",
		},
		wm: {
			type: String,
			default: "",
		},
		handle_user:{
			type: String,
			default: "",
		},
		handle_date:{
			type: String,
			default: "",
		},
		batchNumber:{
			type: String,
			default: "",
		},
		mgroup:{
			type: String,
			default: "",
		},
		mgroupName:{
			type:String,
			default:"",
		},
		dept:{
		    type:String,
			default:"",
		},
		isSubmit:{
			type: Boolean,
			default: false,
		},
		material_out:{
			type:String,
			default:"",
		},
		material_in:{
			type:String,
			default:"",
		},
		processType:{
			type:String,
			default:"",
		},
		test_file:{
		    type:String,
			default:"",
		},
		cutCount:{
		    type:Number,
			default:0,
		}
	},
	emits: ["success", "closed"],
	data() {
		return {
			loading: false,
			headTitle:{
				ins:'输入物料详情',
				outs:'输出物料详情',
			},
			mode:'',
			//表单数据
			form: {
				test_user:"",
				equipment:null,
				cd_req_addr:null,//请求数据接口地址
				equipment_name:"",
				testitemids : [],
				defectids : [],
			},
			test_user_name:"",
			year:"",
			month:"",
			values:"",
			qctId: "",
			wprNumber:"",
			route_code:"",
			wprInputText:"",
			project_code:"",
			test_file_name:"",
			ocr_ip:"",
			ocr_port:"",
			ocr_unit:"",
			canMultiple:false,
			selectedAll:false,
			checkAll: false,
			hideAdd: false,
			hiddenColumns: [],
			columnSettingVisible: false,
			visible: false,
			isSaveing:false,
			setVisible:false,
			multipleSet:false,
			checkVisible:false,
			hasWpr:false,
			pushType:'unshift',
			descriptionVisible:false,
			options:[],
			qct_defects:[],
			qct_testitems:[],
			mlogbwlist:[],
			testitems:[],
			equipmentOptions:[],
			addTemplate:{
                mlogb: "",
                number: "",
                note: "",
				mlogb__batch:"",
                isEdit: true,
            },
			setForm:{
				test_user:"",
				equipment:"",
				equipment_name:"",
				cd_req_addr:null,//请求数据接口地址
				testitemids : [],
				defectids : [],
			},
			rules: {
				test_user: [{ required: true, message: "请选择操作人" }],

			},
			optionsEq:[],
			optionsTooling:[],
			defectlists:[],
			testitemlists:[],
			selectWprList:[],
			selectedindexes:[],
			qct_defects_origin:[],
			openedActionMenu: null,
			tableHeight:500,
			apiObjPrint:this.$API.cm.labelmat.fromWm,
			printer_name:localStorage.getItem("printer_name"),
			// checkTemplate: " /media/default/template/material.xlsx",
		};
	},
	watch: {},
	computed: {
		allColumnOptions() {
			const cols = [];
			if (this.route_code === 'niuzhuan') {
				cols.push({ key: 'equip', label: '生产设备' });
				cols.push({ key: 'time', label: '扭转日期' });
			}
			if (this.mgroupName === '喷码') {
				cols.push({ key: 'tooling', label: '工装' });
			}
			this.qct_testitems.forEach(item => {
				cols.push({ key: 'testitem_' + item.id, label: item.testitem_name });
			});
			this.qct_defects.forEach(item => {
				cols.push({ key: 'defect_' + item.id, label: item.defect_name });
			});
			cols.push({ key: 'note', label: '备注' });
			return cols;
		},
	},
	mounted() {
		let that = this;
		if(that.test_file!==''&&that.test_file!==null){
			that.test_file_name = that.test_file.split("/")[that.test_file.split("/").length-1];
		}
		that.route_code = that.$route.path.split("/")[2];
		that.currentDate = that.$TOOL.dateFormat2(new Date());
		that.project_code = this.$TOOL.data.get("BASE_INFO").base.base_code;
		that.checkTemplate = this.checkTemplate+"?t=" + new Date().getTime();
		if(that.processType=='20'){
			that.canMultiple = true;
		}
		if(that.route_code=='niuzhuan'){
			that.getEquipment4();
		}
		if(that.mgroupName=='喷码'){
			that.getToolings();
		}
		if(that.qct!==''&&that.qct!==null){//输出
			that.getdefects();
		}else{
			if(that.route_code=='niuzhuan'&&that.material_in!==''&&that.material_in!==null){//输入
				if(that.route_code=='chengpingfanxiu'){
					that.$API.qm.qct.getQct.req({ material: that.material_in,type:'out',tag:'fix' }).then((res) => {
						that.qctId = res.id;
						that.testdefectss(res);
					}).catch(()=>{
						that.getList();
					})
				}else{
					that.$API.qm.qct.getQct.req({ material: that.material_in,type:'in',tag:'process' }).then((res) => {
						that.qctId = res.id;
						that.testdefectss(res);
					}).catch(()=>{
						that.getList();
					})
				}
			}else if(that.material_out!==''&&that.material_out!==null){//输入
				that.$API.qm.qct.getQct.req({ material: that.material_out,type:'out',tag:'process' }).then((res) => {
					that.qctId = res.id;
					that.testdefectss(res);
				}).catch(()=>{
					that.getList();
				})
			}
		}
		that.visible = true;
		setTimeout(() => {
			that.tableHeight = document.getElementById('mlogbwMain').clientHeight-20;
		},500)
		that.actionMenuClickHandler = (event) => that.handleDocumentClick(event);
		document.addEventListener("click", that.actionMenuClickHandler, true);
		that.ocr_ip = localStorage.getItem("ocr_ip") || "";
		that.ocr_port = localStorage.getItem("ocr_port") || "";
		that.ocr_unit = localStorage.getItem("ocr_unit") || "";
		
	},
	beforeUnmount() {
		if (this.actionMenuClickHandler) {
			document.removeEventListener("click", this.actionMenuClickHandler, true);
		}
	},
	methods: {
		isColVisible(key) {
			return !this.hiddenColumns.includes(key);
		},
		toggleColumn(key) {
			const idx = this.hiddenColumns.indexOf(key);
			if (idx > -1) {
				this.hiddenColumns.splice(idx, 1);
			} else {
				this.hiddenColumns.push(key);
			}
		},
		refreshfun(){
			this.getList();
		},
		actionMenuKey(row, index) {
			return row.id || `new-${index}`;
		},
		toggleActionMenu(key) {
			this.openedActionMenu = this.openedActionMenu === key ? null : key;
		},
		handleDocumentClick(event) {
			if (event.target && event.target.closest(".action-more")) {
				return;
			}
			if (event.target && event.target.closest(".col-setting-float-panel")) {
				return;
			}
			this.openedActionMenu = null;
			this.columnSettingVisible = false;
		},
		openColumnSetting() {
			this.columnSettingVisible = !this.columnSettingVisible;
		},
		check_add(){
			let that = this;
			that.addTemplate.mlogb__batch = that.mlogb__batch;
			that.addTemplate.isEdit = true;
			that.addTemplate.canEdit = true;
			that.mlogbwlist.unshift(Object.assign({},that.addTemplate));
		},
		selectChange(){
			let that = this;
			that.selectWprList = [];
			that.mlogbwlist.forEach((item) => {
				if(that.selectedindexes.indexOf(item.id)>-1){
					that.selectWprList.push(item);
				}
			})
		},
		selectAllChange(){
			let that = this;
			if(that.selectedAll){
				that.mlogbwlist.forEach((item) => {
					that.selectedindexes.push(item.id);
					that.selectWprList.push(item);
				})
			}else{
				that.selectedindexes=[];
				that.selectWprList=[];
			}
		},
		getEquipment4() {
			let that = this;
			that.$API.em.equipment.list.req({page:0,cate__code:"4",query:"{id,name,number}"}).then((res) => {
				that.optionsEq = res.reverse();
			})
		},
		getToolings() {
			let that = this;
			that.$API.em.equipment.list.req({page:0,type:10,cate__code:"7",query:"{id,name,number}"}).then((res) => {
				that.optionsTooling = Array.isArray(res) ? res : (res.results || []);
			})
		},
		getToolingName(id) {
			if (!id) return '';
			const item = this.optionsTooling.find(t => t.id == id);
			return item ? item.name : id;
		},
		autoSyncTooling() {
			const that = this;
			if (that.mgroupName !== '喷码') return;
			that.mlogbwlist.forEach((row) => {
				const wprTooling = row.wpr_pre_info?.tooling;
				if (wprTooling && row.tooling != wprTooling && row.id) {
					that.$API.wpm.mlogbw.update.req(row.id, { tooling: wprTooling,number:row.number,mlogb:row.mlogb }).then((res) => {
						row.tooling = res.tooling;
						row.tooling_name = res.tooling_name;
						row.tooling_number = res.tooling_number;
					}).catch(() => {});
				}
			});
		},
		getEquipments(){
			let that = this;
			that.$API.em.equipment.list.req({page:0,cate__code:"6"}).then((res) => {
				that.equipmentOptions = res;
			})
		},
		getdefects(){
			let that = this;
			that.$API.qm.qct.item.req(that.qct).then((res) => {
				that.qct_defects = [];
				that.testdefectss(res);
			})
		},
		testdefectss(res){
			let that = this;
			res.qct_defects.forEach((item) => {
				that.addTemplate[item.defect_name] = false;
				let obj = Object.assign({}, item);
				obj.canEdit = that.processType=='20'?false:true;
				that.qct_defects.push(obj);
			})
			that.qct_defects_origin = that.qct_defects;
			that.qct_testitems = [];
			res.qct_testitems.forEach((item2) => {
				if(item2.testitem_type!=='20'){
					let obj2 = Object.assign({}, item2);
					obj2.value = '';
					obj2.canEdit = that.processType=='20'?false:true;
					
					obj2.addto_wpr = item2.addto_wpr;
					if(item2.testitem_field_type=='input-number'||item2.testitem_field_type=='input-int'){
						obj2.value = null;
						if(item2.testitem_name == '切片数'){
							obj2.value = Number(that.cutCount);
						}
						that.addTemplate[item2.testitem_name] = null;
					}
					if(item2.testitem_field_type=='select-text'||item2.testitem_field_type=='selects-text'){
						let str = obj2.testitem_choices.replace(/'/g, '"');
						let arr = JSON.parse(str);
						obj2.testitem_choices = arr;
						that.addTemplate[item2.testitem_name] = null;
					}
					that.qct_testitems.push(obj2);
				}
			})
			that.qct_testitems_origin = that.qct_testitems;
			that.getList();
		},
		getOptions(){
			let that = this;
			that.$API.wpm.wpr.list.req({wm:that.wm,page:0,query:"{id,number}"}).then((res) => {
				that.options = res;
			})
		},
		timeChange(row){
			let that = this;
			let index = that.mlogbwlist.indexOf(row);
			if(row.work_start_time!==''&&row.work_start_time!==null&&row.work_start_time!==undefined){
				let waveNum = 1;
				let hours = 0,minutes=0;
				if(row.work_start_time.indexOf("T")>-1){
					hours =Number(row.work_start_time.split("T")[1].split(":")[0]);
					minutes =Number(row.work_start_time.split("T")[1].split(":")[1]) ;
				}else{
					hours =Number(row.work_start_time.split(" ")[1].split(":")[0]);
					minutes =Number(row.work_start_time.split(" ")[1].split(":")[1]) ;
				}
				if((hours==0&&minutes>29)||hours==1||(hours==2&&minutes<30)){
					waveNum = 9;
				}else if((hours==2&&minutes>29)||hours==3||(hours==4&&minutes<30)){
					waveNum = 10;
				}else if(hours==7||hours==8){
					waveNum = 1;
				}else if(hours==9||hours==10){
					waveNum = 2;
				}else if(hours==11||hours==12){
					waveNum = 3;
				}else if((hours==13&&minutes>29)||hours==14||(hours==15&&minutes<30)){
					waveNum = 4;
				}else if((hours==15&&minutes>29)||hours==16||(hours==17&&minutes<30)){
					waveNum = 5;
				}else if(hours==18||hours==19){
					waveNum = 6;
				}else if(hours==20||hours==21){
					waveNum = 7;
				}else if(hours==22||hours==23){
					waveNum = 8;
				}
				that.mlogbwlist[index].波数 = waveNum;
			}else{
				that.mlogbwlist[index].波数 = null;
			}
		},
		getList(){
			let that = this;
			let params = {};
			that.mlogbwlist = [];
			params.page = 0;
			params.type = 'out';
			params.mlogb__mlog = that.mlogId;
			that.$API.wpm.mlogbw.list.req(params).then((res) => {
				that.mlogbwlist = [];
				if(res.length>0){
					that.addTemplate.mlogb = that.mlogb = res[0].mlogb;
					that.addTemplate.mlogb__batch = that.mlogb__batch = res[0].mlogb__batch;
					res.forEach((item) => {
						let obj = {};
					    obj = Object.assign({},item);
                    	obj.isEdit = false;
						if(that.qct!=''){
							if(item.ftest!=null){
								if(item.ftest.ftestdefects!==undefined&&item.ftest.ftestdefects!==''&&item.ftest.ftestdefects!==null&&item.ftest.ftestdefects.length>0){
									item.ftest.ftestdefects.forEach((item1) => {
										obj[item1.defect_name] = item1.has;
									})
								}
								if(item.ftest.ftestitems!==undefined&&item.ftest.ftestitems!==''&&item.ftest.ftestitems!==null&&item.ftest.ftestitems.length>0){
									item.ftest.ftestitems.forEach((item2) => {
										obj[item2.testitem_name] = item2.test_val_json;
									})
								}
							}else{
								that.qct_defects.forEach((item1) => {
									obj[item1.defect_name] = false;
								})
								that.qct_testitems.forEach((item2) => {
									if(item2.testitem_name == '切片数'){
										obj[item2.testitem_name] = Number(that.cutCount);
									}else{
										obj[item2.testitem_name] = null;
									}
								})
							}
						}
						that.mlogbwlist.push(obj);
					})
				}
				that.$nextTick(() => {
					that.autoSyncTooling();
				});
			})
		},
		widthFun(item){
			if(item.defect_name.indexOf('黑网')!=-1|| item.defect_name.indexOf('白网')!=-1||item.defect_name.indexOf('小网')!=-1){
				return '54px';
			}else{
				return '';
			}
		},
        //添加
		formTableSave(row,index) {
			let that = this;
			let editIndex = 0;
			that.mlogbwlist.forEach((item,index) => {
				if(item.id==row.id){
					editIndex = index;
				}
			})
			let obj = {};
			obj.number = row.number;
			obj.mlogb = row.mlogb;
			obj.wpr = row.wpr;
			obj.note = row.note;
			if(row.work_start_time){
				obj.work_start_time = row.work_start_time.replace('T',' ');
			}
			if(row.equip){
				obj.equip = row.equip;
			}
			if(row.tooling){
				obj.tooling = row.tooling;
			}
			//qct不为空，有检验表
			if((that.qct!==''&&that.qct!==null)||(that.qctId!==''&&that.qctId!==null)){
				obj.ftest = {};
				obj.ftest.ftestitems = [];
				obj.ftest.ftestdefects = [];
				obj.ftest.qct = that.qct;
				obj.ftest.test_date = that.handle_date!=null?that.handle_date:that.currentDate;
				obj.ftest.test_user = that.handle_user;
				if(that.qct_defects.length>0){
					that.qct_defects.forEach((item) => {
						let itemObj = {};
						itemObj.defect = item.defect;
						itemObj.test_user = that.handle_user;
						itemObj.has = row[item.defect_name]?row[item.defect_name]:false;
						obj.ftest.ftestdefects.push(itemObj);
					})
				}
				if(that.qct_testitems.length>0){
					that.qct_testitems.forEach((item1) => {
						let itemObj1 = {};
						itemObj1.testitem = item1.testitem;
						itemObj1.test_user = that.handle_user;
						itemObj1.addto_wpr = item1.addto_wpr;
						itemObj1.test_val_json = row[item1.testitem_name];
						obj.ftest.ftestitems.push(itemObj1);
					})
				}
			}else{
				obj.ftest = null;
			}
			//当前工段为‘排一次棒’的时候，将batch改为number；
			if(that.mgroupName=='排一次棒'){
				that.$API.wpm.mlogb.patchOut.req(row.mlogb, { batch: row.number }).then((res) => {
					that.mlogbwlist[index].mlogb__batch = row.number;
				})
			}
            if(row.id!==''&&row.id!==undefined&&row.id!==null){
				obj.id = row.id;
				that.$API.wpm.mlogbw.update.req(row.id,obj).then((res) => {
					that.$message.success("保存成功");
					that.mlogbwlist[editIndex].isEdit = false;
					that.mlogbwlist[editIndex].equip_name = res.equip_name;
					that.mlogbwlist[editIndex].equip_number = res.equip_number;
					that.mlogbwlist[editIndex].tooling_name = res.tooling_name;
					that.mlogbwlist[editIndex].tooling_number = res.tooling_number;
					that.mlogbwlist[editIndex].work_start_time = res.work_start_time;
					// that.getList();
					return res;
				}).catch((err) => {
					return err;
				});
			}else{
				let objNew = {};
				objNew.mlogb = obj.mlogb;
				objNew.number = obj.number;
				objNew.mlogb__batch = that.mlogb__batch;
				that.$API.wpm.mlogbw.create.req(objNew).then((res) => {
					that.$message.success("添加成功");
					that.mlogbwlist[editIndex].isEdit = false;
					that.mlogbwlist[editIndex].equip_name = res.equip_name;
					that.mlogbwlist[editIndex].equip_number = res.equip_number;
					that.mlogbwlist[editIndex].tooling_name = res.tooling_name;
					that.mlogbwlist[editIndex].tooling_number = res.tooling_number;
					that.mlogbwlist[editIndex].work_start_time = res.work_start_time;
					// that.getList();
					return res;
				}).catch((err) => {
					return err;
				});
			}
		},
		formTableCancel(row){
			this.mlogbwlist.forEach((item, index) => {
				if (item.id == row.id) {
					this.mlogbwlist[index].isEdit = false;
				}
			});
		},
        formTableEdit(index) {
            let that = this;
			that.mlogbwlist[index].isEdit = true;
			if(that.mgroupName=='喷码'){
				const wprTooling = that.mlogbwlist[index].wpr_pre_info?.tooling;
				if(wprTooling && that.mlogbwlist[index].tooling != wprTooling){
					that.mlogbwlist[index].tooling = wprTooling;
				}
			}
			let date = new Date();
			if(that.mlogbwlist[index].work_start_time==''||that.mlogbwlist[index].work_start_time==null){
				that.mlogbwlist[index].work_start_time = that.$TOOL.dateFormat(date, 'yyyy-MM-dd hh:mm:ss');
				that.timeChange(that.mlogbwlist[index])
			}
			let getEd = false;
			if(that.qct_testitems.length>0){
				for(let i=0;i<that.qct_testitems.length;i++){
					if(that.qct_testitems[i].testitem_cd_expr!=null&&that.qct_testitems[i].testitem_cd_expr!=''&&that.qct_testitems[i].testitem_cd_expr!==undefined){
						getEd = true;
					}
				}
			}
			if(getEd&&that.setForm.cd_req_addr!==null&&that.setForm.cd_req_addr!==""&&that.setForm.cd_req_addr!==undefined){
				that.getEqData(index);
			}
        },
		formTableDelet(row,index){
			this.mlogbwlist.splice(index, 1);
		},
		//删除
		formTableDel(id,index) {
            let that = this;
			that.$confirm(`确定删除吗？`, "提示", {
				type: "warning",
			}).then(() => {
                that.$API.wpm.mlogbw.delete.req(id).then((res) => {
					that.getList();
					that.mlogbwlist.splice(index,1);
                    that.$message.success("删除成功");
                }).catch((err) => {
                    return err;
                });
            }).catch(() => {});
		},
		switchChange(row,item,index){
			let that = this;
			that.mlogbwlist[index][item.defect_name] = row[item.defect_name];
		},
		//表单提交方法
		mlogbSubmit() {
			let that = this;
			that.$API.wpm.mlogb.submit.req(that.mlogb).then((res) => {
				that.isSaveing = false;
				that.visible = false;
				that.$message.success("操作成功");
			});
		},
		defectCountSun(row){
			let that = this;
			let index = that.mlogbwlist.indexOf(row);
			that.qct_defects.forEach(item => {
				if(item.rule_expression!==''&&item.rule_expression!==undefined&&item.rule_expression!==null){
					let str = item.rule_expression.replace(/`/g, '');
					str = str.replace(/\${(.*?)}/g, 'row.\$1');
					// if(str.indexOf('row.剪切值18mm')>-1){
					// 	if(row.剪切值18mm==null||row.剪切值18mm==''||row.剪切值18mm==undefined){
					// 		str = str.split('||')[0];
					// 	}
					// }
					let judge = false;
					try {
					    judge = eval(str);
						that.mlogbwlist[index][item.defect_name] = judge;
					}catch (error) {
					    console.error(error);
					}
				}else{
					that.mlogbwlist[index][item.defect_name] = false;
				}
			});
		},
		//设置过滤项
		setFilters(filters) {
			this.selectionFilters = filters;
			this.setFiltersVisible = true;
		},
		handlePrint(){
			let that = this;
			that.printVisible = true;
		},
		//打签
		printMaterial(row){
			let that = this;
			that.apiObjPrint.req({tid:row.id}).then((res) => {
				let code = res.code_label;
				let str = [
					"SIZE 40 mm,70 mm",
					"GAP 7 mm,7 mm",
					"CLS",
					"REFERENCE 0,0",
					'QRCODE 30,400,H,5,A,0,"' +code +'"',
					"WINTEXT 200,550,28,90,0,0,Simhei," + res.material_name,
					"WINTEXT 240,550,28,90,0,0,Simhei," +"批次号：" + res.batch,
					"WINTEXT 280,550,28,90,0,0,Simhei," +"数量："  + row.count,
					"PRINT 1",
				]; 
				let obj = {};
				obj.printer_commands = str;
				obj.printer_name = that.printer_name;
                let printer_ip=localStorage.getItem("printer_ip")||'127.0.0.1';
that.$API.wpm.prints.req(printer_ip, obj).then((response) => {
                    that.$message.success("打印成功");
				});
			})
		},
		userChange(val){
			let that = this;
			that.$API.system.user.item.req(val).then((res) => {
				that.setForm.test_user_name = res.name;
			})
		},
		equipmentChange(){
			let that = this;
			that.equipmentOptions.forEach(item => {
				if(item.id == that.form.equipment){
					that.form.equipment_name = item.name;
					that.setForm.equipment_name = item.name;
					that.form.cd_req_addr = that.setForm.cd_req_addr = item.cd_req_addr;
				}
			});
		},
		testitemidsChange(){
			let that = this;
			that.testitemlists = [];
			that.qct_testitems.forEach(item => {
				if(that.form.testitemids.indexOf(item.testitem) > -1){
					item.canEdit = true;
					item.value=null;
					that.testitemlists.push(item);
				}
			});
		},
		defectidsChange(){
			let that = this;
			that.defectlists = [];
			that.qct_defects.forEach(item => {
				if(that.form.defectids.indexOf(item.defect) > -1){
					item.canEdit = true;
					item.value=false;
					that.defectlists.push(item);
				}
			})
			if(that.defectlists.length == that.qct_defects.length){
				that.checkAll = true;
			}else{
				that.checkAll = false;
			}
		},
		handleCheckAll(){
			let that = this;
			that.defectlists = [];
			that.form.defectids = [];
			if(that.checkAll){
				that.qct_defects.forEach(item => {
					item.canEdit = true;
					item.value=false;
					that.defectlists.push(item);
					that.form.defectids.push(item.defect);
				})
			}
		},
		check_start(){
			this.checkVisible=true;
			this.getEquipments();
		},
		checkSetting(){
			let that = this;
			that.isSaveing = true;
			that.$refs.dialogForm.validate((valid) => {
				if (valid) {
					let obj = {};
					obj.mlogbw_ids = that.mlogbwlist.map(item => item.id).filter(id => id !== undefined && id !== null && id !== '');
					obj.test_equip = that.form.equipment;
					obj.test_user = that.form.test_user;
					obj.test_date = that.handle_date!=null?that.handle_date:that.currentDate;
					if(that.form.defectids.length>0){
						obj.defects = that.form.defectids;
						that.setForm.defectids = that.form.defectids;
					}
					if(that.form.testitemids.length>0){
						obj.testitems = that.form.testitemids;
						that.setForm.testitemids = that.form.testitemids;
					}
					obj.qct =  that.qct!==null?that.qct:that.qctId;
					that.$API.wpm.mlogbw.start_test.req(obj).then((res) => {
						that.isSaveing = false;
						that.form = {};
						that.checkVisible = false;
						that.multipleSet = true;
						that.descriptionVisible = true;
						that.qct_defects = [];
						that.qct_defects = that.defectlists;
						that.qct_testitems = [];
						that.qct_testitems = that.testitemlists;
						that.tableHeight = document.getElementById('mlogbwMain').clientHeight-80;
						this.getList();
					}).catch(() => {
					    that.isSaveing = false;
					})
				}else{ that.isSaveing = false;}
			});
		},
		saveCancel(){
			this.form = {};
			this.form.test_user = "";
			this.form.equipment = "";
			this.form.testitemids = [];
			this.form.defectids = [];
			this.checkVisible = false;
		},
		//批量操作
		check_set(){
			let that = this;
			that.wprNumber = "";
			that.setVisible=true;
		},


		//扫描这里更新：添加数字化识别，调用一个接口，并且返回number和设备数据，然后根据number将这一行放到第一行并编辑这一行，并且把设备数据放到对应位置
		digital(){
			let that = this;
			//第一步：调用接口获取数字识别设备返回的number
			if(!that.ocr_ip || !that.ocr_port || !that.ocr_unit){
				that.$message.warning('请先在右上角"数字识别设置"配置IP、端口号和位号');
				return;
			}
			that.$API.em.equipment.get_svs_char.req({
				host: that.ocr_ip,
				port: that.ocr_port,
				flow_unit: that.ocr_unit
			}).then((res) => {
				if(res.char){
					that.mlogbwlist.forEach((item,index) => {
						if(item.number==res.char){
							let obj = Object.assign({},item);S
							obj.isEdit = true;
							that.mlogbwlist.splice(index,1);
							that.wprInputText = "";
							that.mlogbwlist.unshift(obj);
							that.$nextTick(() => {
								that.selectedindexes.push(obj.id);
								that.selectWprList.push(item);
							})
							//第二步：获取投影仪设备的监测数据
							//先判断是否有需要检测设备的检测项，若有，赋值，若无，跳过
							if(that.qct_testitems.length>0 && !!that.setForm.cd_req_addr){
								that.$API.em.cd.req({method:that.setForm.cd_req_addr}).then((res) => {
									that.qct_testitems.forEach(item0 => {
										if(item0.testitem_cd_expr!=null){
											that.mlogbwlist[0][item0.testitem_name]= eval(item0.testitem_cd_expr);
											item0.cd_expr = true;
											that.qct_defects.forEach(item => {
												if(item.rule_expression!==''&&item.rule_expression!==undefined&&item.rule_expression!==null){
													let str = item.rule_expression.replace(/`/g, '');
													str = str.replace(/\${(.*?)}/g, 'row.\$1');
													let judge = false;
													try {
														judge = eval(str);
														that.mlogbwlist[0][item.defect_name] = judge;
													}catch (error) {
														console.error(error);
													}
												}else{
													that.mlogbwlist[0][item.defect_name] = false;
												}
											});
										}
									})
									let arrs=  that.qct_testitems.filter(item => item.testitem_cd_expr!=null)
									if(arrs.length>0){
										that.seveAuto(0);
									}
								}).catch((err) => {
									this.$notify.error({
										title: '获取数据失败',
										message: err.data
									})
									return err;
								});
							}
						}
					})
				}
			}).catch((err) => {
				that.$notify.error({
					title: '数字识别获取失败',
					message: err.data
				})
				return err;
			});
		},
		seveAuto(index){
			let that= this;
			let arr2 =	that.mlogbwlist.filter(item => item.cd_expr==true);
			if(arr2.length>0){
				that.formTableSave(that.mlogbwlist[index],index);
			}else{
				setTimeout(() => {
					that.seveAuto(index);
				}, 500);
			}
		},

		//扫描物料将这一行放到第一行并编辑这一行
		wprinputChange(){
			let that = this;
			that.mlogbwlist.forEach((item,index) => {
				let indexs = item.number.indexOf(that.wprInputText)
				if(indexs>-1&&that.wprInputText !== ""){
					let obj = Object.assign({},item);
					obj.isEdit = true;
					that.mlogbwlist.splice(index,1);
					that.wprInputText = "";
					that.mlogbwlist.unshift(obj);
					that.$nextTick(() => {
						that.selectedindexes.push(obj.id);
						that.selectWprList.push(item);
					})
					let getEd = false;
					if(that.qct_testitems.length>0){
						for(let i=0;i<that.qct_testitems.length;i++){
							if(that.qct_testitems[i].testitem_cd_expr!=null&&that.qct_testitems[i].testitem_cd_expr!=''&&that.qct_testitems[i].testitem_cd_expr!==undefined){
								getEd = true;
							}
						}
					}
					if(getEd&&that.setForm.cd_req_addr!==null&&that.setForm.cd_req_addr!==""&&that.setForm.cd_req_addr!==undefined){
						//执行cd_req_addr,获取检测设备的数据
						that.getEqData(0);
					}
				}
			})
		},
		getEqData(index){
			let that = this;
			let row = that.mlogbwlist[index];
			that.$API.em.cd.req({method:that.setForm.cd_req_addr}).then((res) => {
				that.qct_testitems.forEach(item0 => {
					if(item0.testitem_cd_expr!=null){
						that.mlogbwlist[index][item0.testitem_name]= eval(item0.testitem_cd_expr);
						that.mlogbwlist[index].cd_expr = true;
						that.qct_defects.forEach(item => {
							if(item.rule_expression!==''&&item.rule_expression!==undefined&&item.rule_expression!==null){
								let str = item.rule_expression.replace(/`/g, '');
								str = str.replace(/\${(.*?)}/g, 'row.\$1');
								let judge = false;
								try {
									judge = eval(str);
									that.mlogbwlist[index][item.defect_name] = judge;
								}catch (error) {
									console.error(error);
								}
							}else{
								that.mlogbwlist[index][item.defect_name] = false;
							}
						});
					}
				})
				let arrs=  that.qct_testitems.filter(item => {return item.testitem_cd_expr!=null;})
				if(arrs.length>0){
					that.seveAuto(index);
				}
			}).catch((err) => {
				this.$notify.error({
					title: '获取数据失败',
					message: err.data
				})
				return err;
			});
		},
		wprChange(wprNumber){
			let that = this;
			that.mlogbwlist.forEach(item => {
				if(item.number == wprNumber){
					that.selectWprList.push(item);
					that.wprNumber = "";
				}
			});
		},
		selectWprDel(row){
			let that = this;
			that.selectWprList.forEach((item,index) => {
				if(item.number == row.number){
					that.selectWprList.splice(index,1);
				}
			});
		},
		defect_change(item){
			let that = this;
			that.selectWprList.forEach(row => {
				row[item.defect_name] = item.value;
			});
		},
		saveSetting(){
			let that = this;
			that.$refs.dialogForm.validate((valid) => {
				if (valid) {
					that.selectWprList.forEach(item => {
						delete item.ftestitems;
						if(!item.ftest){
							item.ftest = {};
						}
						item.ftest.ftestdefects = [];
						if(that.defectlists.length>0){
							that.defectlists.forEach((item1) => {
								let obj = {};
								obj.defect = item1.defect;
								obj.has = item[item1.defect_name]?item[item1.defect_name]:false;
								item.ftest.ftestdefects.push(obj);
							})
						}
					});
					that.$API.wpm.mlogbw.update.req("bulk",that.selectWprList).then((res) => {
						that.setVisible = false;
						that.selectedAll = false;
						that.selectWprList = [];
						that.selectedindexes = [];
						that.defectlists.forEach(item => {
							item.value = false;
						});
						that.getList();
					}).catch((err) => {
						return err;
					});
				}
			});
		},
		saveSettingCancel(){
			let that = this;
			that.setVisible = false;
			that.selectedAll = false;
			that.selectWprList = [];
			that.selectedindexes = [];
			// that.defectlists.forEach(item => {
			// 	item.value = false;
			// });
		},
		upSuccess(res, close){
			let that = this;
			close();
			const loading = ElLoading.service({
				fullscreen: true,
				text: "解析中...请稍等",
			});
			this.$API.wpm.mlog.change.req(that.mlogId,{ test_file: res.path }).then((res) => {
					loading.close();
					this.$message.success("导入成功");
					this.getList();
				}).catch((err) => {
					loading.close();
					this.$message.error("导入失败，请重新尝试");
				});
		},
		hasNull(){
			let that = this;
			let canSubmit = true;
			that.mlogbwlist.forEach(item=>{
				that.qct_testitems.forEach(testitem=>{
					if(item[testitem.testitem_name]==null||item[testitem.testitem_name]==''||item[testitem.testitem_name]==undefined){
						canSubmit =  false;
					}
				})
			})
			return canSubmit;
		},
	},
};
</script>

<style scoped>
#mlogbwMain{
	position: relative;
}
.table-scroll{
	width: 100%;
	height: 400px;
	overflow-x: auto;
	overflow-y: auto;
}
.width-100{
	width: 100%;
}
table {
	border-collapse: separate;
	border-spacing: 0;
}
.tables {
	width: max-content;
	min-width: 100%;
}
table {
	color: #606266;
	border-top: 1px solid #ebeef5;
	border-left: 1px solid #ebeef5;
}
tbody tr:nth-child(odd) {
	background-color: #f5f7fa;

}
th{
	text-align: left;
	position: sticky;
	top: 0;
	z-index: 3;
	background: #fff;
	padding: 12px 5px;
	min-height: 40px;
	font-size: 12px;
	color: #909399;
	word-break: break-all;
	border-right: 1px solid #ebeef5;
	border-bottom: 1px solid #ebeef5;
}
tr{
	min-height: 40px;
}
td {
	padding: 5px;
	min-height: 40px;
	line-height: 30px;
	text-align: left;
	border-right: 1px solid #ebeef5;
	border-bottom: 1px solid #ebeef5;
}
input{
	width: 100%;
    height: 100%;
    border: none;
    padding: 0 2px;
}
.checkboxInput{
	width: 14px;
    height: 14px;
}
.w_50{
	width: 50px;
}
.w_80{
	width: 80px;
	min-width: 80px;
}
.w_120{
	width: 120px;
	min-width: 120px;
}
.w_140{
	width: 140px;
	min-width: 140px;
}
.w_150{
	width: 150px;
	min-width: 150px;
}
.w_180{
	width: 180px;
	min-width: 180px;
}
.sticky-cell{
	position: sticky;
	background: #fff;
	z-index: 2;
}
thead .sticky-cell{
	z-index: 6;
}
tbody tr:nth-child(odd) .sticky-cell{
	background-color: #f5f7fa;
}
.sticky-left-select{
	left: 0;
}
.sticky-left-index{
	left: 50px;
}
.sticky-left-batch{
	left: 100px;
}
.sticky-left-number{
	left: 240px;
}
.sticky-right-action{
	right: 0;
	box-shadow: -2px 0 6px rgba(0, 0, 0, 0.08);
}
.sticky-left-select,
.sticky-left-index,
.sticky-left-batch,
.sticky-left-number{
	box-shadow: 2px 0 0 #ebeef5;
}

.padding_4{
	padding: 4px; /* 添加内边距 */
}
.operation-cell{
	position: sticky;
	overflow: visible;
	z-index: 5;
}
.operation-cell.is-menu-open{
	z-index: 8;
}
.action-more{
	position: absolute;
	right: 8px;
	bottom: 6px;
	display: inline-flex;
	flex-direction: column;
	align-items: center;
}
.more-trigger{
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 3px;
	width: 24px;
	height: 24px;
	padding: 0;
	border: none;
	background: transparent;
	cursor: pointer;
}
.more-trigger span{
	width: 4px;
	height: 4px;
	border-radius: 50%;
	background: #909399;
}
.action-more:hover .more-trigger span{
	background: #606266;
}
.more-menu{
	position: absolute;
	right: 0;
	bottom: 28px;
	min-width: 72px;
	padding: 6px 0;
	border: 1px solid #ebeef5;
	border-radius: 4px;
	background: #fff;
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
	z-index: 12;
}
.more-menu-btn{
	display: block;
	width: 100%;
	padding: 6px 12px;
	border: none;
	background: transparent;
	color: #f56c6c;
	text-align: left;
	cursor: pointer;
}
.more-menu-btn:hover{
	background: #fef0f0;
}
.col-setting-float-panel{
	position: absolute;
	right: 0;
	top: 35px;
	z-index: 100;
	background: #fff;
	border: 1px solid #ebeef5;
	border-radius: 4px;
	box-shadow: 0 2px 12px rgba(0,0,0,0.12);
	padding: 8px 12px;
	min-width: 150px;
	max-height: 300px;
	overflow-y: auto;
}
.col-setting-item{
	padding: 4px 0;
	line-height: 1.6;
}
.btn{
    margin:0 5px;
    border: none;
    color: #ffffff;
    font-size: 12px;
    border-radius: 4px;
    width: 55px;
    height: 30px;
    line-height: 28px;
}
.btn_red{
    background: #ff0000;
}
.btn_blue{
    background: #2965f2;
}
.btn_green{
    background: #28b208;
}
.btn_yellow{
    background: #f9db45;
}
</style>
