|
|
@@ -1564,6 +1564,19 @@
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
|
|
|
+ <!-- JP机新增定额代号弹窗 -->
|
|
|
+ <el-dialog v-model="FJPGetDedhVisible" id="tableFplb" @keydown="FJPent($event)" style="margin-top: 5%;" >
|
|
|
+ <el-form>
|
|
|
+ <el-form-item label="选择定额代号" class="mab" prop="keyOrder"></el-form-item>
|
|
|
+ <div style="border:1px solid #eee; width:100%; height: 600px; overflow-y: auto;">
|
|
|
+ <el-tree :data="FJPGetDedhtreeData" ref="FJPtable_fplb"
|
|
|
+ @keydown="FJPhandleTreeKeydown"
|
|
|
+ :props="{ children: 'children',label: 'label'}"
|
|
|
+ node-key="id" @node-click="FJPhandleFplbClick">
|
|
|
+ </el-tree>
|
|
|
+ </div>
|
|
|
+ </el-form>
|
|
|
+ </el-dialog>
|
|
|
|
|
|
<!-- JP机台独立页面 新增-->
|
|
|
<el-dialog v-model="JPchanliangVisible" :before-close="JPcloseDialog" style="width: 60%;margin-top: 5%;" :title="'新增班组产量提报'" destroy-on-close>
|
|
|
@@ -6254,6 +6267,180 @@ const tablebllickHandlerlist = async (row, column, event) => {
|
|
|
};
|
|
|
|
|
|
|
|
|
+/*
|
|
|
+ 除JP定额代号弹窗
|
|
|
+*/
|
|
|
+const FJPGetDedhtreeData = reactive([]);
|
|
|
+const FJPGetDedhVisible = ref(false);
|
|
|
+const FJPtable_fplb = ref(null); // el-tree 的 ref
|
|
|
+const FJPgetDedhsubmit = async () => {
|
|
|
+try {
|
|
|
+ const response = await productionDedh({
|
|
|
+ sczl_jtbh: formdata3.value.sczl_jtbh, // 请求参数
|
|
|
+ });
|
|
|
+
|
|
|
+ if (response.code === 0) {
|
|
|
+ const data = response.data;
|
|
|
+
|
|
|
+ // 处理单条记录的情况,直接赋值
|
|
|
+ if (!Array.isArray(data) && !data.bh_mc) {
|
|
|
+ formdata3.value.dedh = data.sys_bh;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 定义递归函数,用于构造树形结构
|
|
|
+ const buildTree = (node) => {
|
|
|
+ const treeNode = {
|
|
|
+ id: node.sys_bh,
|
|
|
+ label: node.sys_bh + (node.sys_mc ? `【${node.sys_mc}】` : ""), // 显示内容
|
|
|
+ children: [],
|
|
|
+ key: node.Key_ || node.sys_bh, // 保留 key 属性,用于操作
|
|
|
+ };
|
|
|
+
|
|
|
+ // 如果有子节点,递归处理
|
|
|
+ if (node.bh_mc && Array.isArray(node.bh_mc)) {
|
|
|
+ treeNode.children = node.bh_mc.map((childNode) => buildTree(childNode));
|
|
|
+ }
|
|
|
+
|
|
|
+ return treeNode;
|
|
|
+ };
|
|
|
+
|
|
|
+ // 处理数组数据结构,生成树形结构并展示弹窗
|
|
|
+ if (Array.isArray(data)) {
|
|
|
+ FJPGetDedhtreeData.splice(
|
|
|
+ 0,
|
|
|
+ FJPGetDedhtreeData.length,
|
|
|
+ ...data.map((item) => ({
|
|
|
+ id: item.sys_bh,
|
|
|
+ label: item.sys_bh,
|
|
|
+ children: [],
|
|
|
+ key: item.sys_bh,
|
|
|
+ }))
|
|
|
+ );
|
|
|
+ FJPGetDedhVisible.value = true; // 展示弹窗
|
|
|
+ }
|
|
|
+
|
|
|
+ // 处理嵌套的树形结构数据
|
|
|
+ if (!Array.isArray(data) && data.bh_mc) {
|
|
|
+ FJPGetDedhtreeData.splice(0, FJPGetDedhtreeData.length, buildTree(data));
|
|
|
+ FJPGetDedhVisible.value = true; // 展示弹窗
|
|
|
+ }
|
|
|
+
|
|
|
+ // 使用 nextTick 确保树形组件渲染完成后执行操作
|
|
|
+ nextTick(() => {
|
|
|
+ const tree = FJPtable_fplb.value; // 获取树形组件实例
|
|
|
+ if (tree) {
|
|
|
+ const firstNode = tree.getNode(0); // 获取树形的第一个节点
|
|
|
+ if (firstNode) {
|
|
|
+ firstNode.el.focus(); // 聚焦到第一个节点
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error("获取数据失败:", error);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+//键盘事件
|
|
|
+const FJPhandleTreeKeydown = (event) => {
|
|
|
+ const tree = FJPtable_fplb.value; // 获取树实例
|
|
|
+ if (!tree) {
|
|
|
+ console.error("树组件未加载");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const focusedElement = document.activeElement;
|
|
|
+ const focusedNodeId = focusedElement?.getAttribute("data-key"); // 获取 DOM 的 data-key 属性
|
|
|
+
|
|
|
+ if (event.keyCode === 13 && focusedNodeId) { // 判断是否是回车键
|
|
|
+ tree.setCurrentKey(focusedNodeId); // 设置当前节点为选中
|
|
|
+ tree.$nextTick(() => {
|
|
|
+ const currentNode = tree.getCurrentNode(); // 获取当前选中的节点
|
|
|
+ if (!currentNode) {
|
|
|
+ console.warn("没有选中的节点");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 清除上一次的选中状态
|
|
|
+ FJPclearPreviousSelection(tree);
|
|
|
+ // 收起所有其他节点
|
|
|
+ Object.keys(tree.store.nodesMap).forEach((key) => {
|
|
|
+ tree.store.nodesMap[key].expanded = false; // 收起所有节点
|
|
|
+ });
|
|
|
+
|
|
|
+ // 展开当前节点
|
|
|
+ tree.store.nodesMap[currentNode.id].expanded = true;
|
|
|
+
|
|
|
+ // 如果当前节点有子节点,选中第一个子节点
|
|
|
+ if (currentNode.children && currentNode.children.length > 0) {
|
|
|
+ const firstChild = currentNode.children[0];
|
|
|
+ if (firstChild) {
|
|
|
+ const firstChildKey = firstChild.id.toString();
|
|
|
+ tree.setCurrentKey(firstChildKey); // 设置第一个子节点为选中
|
|
|
+ setTimeout(() => {
|
|
|
+ const firstChildDom = tree.$el.querySelector(`[data-key="${firstChildKey}"]`);
|
|
|
+ if (firstChildDom) {
|
|
|
+ firstChildDom.focus();
|
|
|
+ firstChildDom.scrollIntoView({ block: "nearest" });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.log("当前子节点:", currentNode.label);
|
|
|
+ // 如果节点没有子节点,打印节点名称
|
|
|
+ formdata3.value.dedh = currentNode.label.split("【")[0];
|
|
|
+ FJPGetDedhVisible.value = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else if (event.keyCode === 38 || event.keyCode === 40) { // 上下箭头键
|
|
|
+ const currentNode = tree.getCurrentNode();
|
|
|
+ if (currentNode) {
|
|
|
+ const currentNodeDom = tree.$el.querySelector(`[data-key="${currentNode.id}"]`);
|
|
|
+ if (currentNodeDom) {
|
|
|
+ currentNodeDom.focus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// 清除之前的选中状态
|
|
|
+const FJPclearPreviousSelection = (tree) => {
|
|
|
+ const selectedNodes = tree.getCheckedNodes();
|
|
|
+ selectedNodes.forEach(node => {
|
|
|
+ tree.setChecked(node, false);
|
|
|
+ });
|
|
|
+ tree.setCurrentKey(null);
|
|
|
+};
|
|
|
+
|
|
|
+// 弹出框键盘事件
|
|
|
+const FJPent = (event) => {
|
|
|
+ if (document.activeElement.id === "tableFplb") {
|
|
|
+ if (FJPtable_fplb.value) {
|
|
|
+ const tree = FJPtable_fplb.value?.$el;
|
|
|
+ if (tree) {
|
|
|
+ const node = tree.querySelector("[data-key]");
|
|
|
+ if (event.keyCode === 13) {
|
|
|
+ // GetDedhVisible.value = false;
|
|
|
+ }
|
|
|
+ if (node) {
|
|
|
+ node.scrollIntoView({ block: "nearest" }); // 确保节点可见
|
|
|
+ node.focus(); // 确保焦点正确
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+//点击事件
|
|
|
+const FJPhandleFplbClick = (nodeData, node, component) => {
|
|
|
+ //存放当前节点的nodeId
|
|
|
+ if (!nodeData.children || nodeData.children.length === 0) {
|
|
|
+ // 如果节点没有子节点,打印节点名称
|
|
|
+ formdata3.value.dedh= nodeData.label.split("【")[0];
|
|
|
+ FJPGetDedhVisible.value = false;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
/*
|
|
|
JP定额代号弹窗
|
|
|
*/
|
|
|
@@ -6524,7 +6711,7 @@ const handleTreeKeydownedit = (event) => {
|
|
|
return;
|
|
|
}
|
|
|
// 清除上一次的选中状态
|
|
|
- clearPreviousSelection(tree);
|
|
|
+ clearPreviousSelectionedit(tree);
|
|
|
// 收起所有其他节点
|
|
|
Object.keys(tree.store.nodesMap).forEach((key) => {
|
|
|
tree.store.nodesMap[key].expanded = false; // 收起所有节点
|
|
|
@@ -6944,11 +7131,28 @@ if(selected.value==='难度调整系数'){
|
|
|
}
|
|
|
|
|
|
|
|
|
- const ent1 = (event) => {
|
|
|
+ const ent1 = async (event) => {
|
|
|
const inputs = document.getElementsByTagName('input');
|
|
|
const currentIndex = Array.from(inputs).indexOf(event.target);
|
|
|
|
|
|
if (event.keyCode === 13 || event.keyCode === 40) { // Enter 或向下箭头
|
|
|
+ if (event.target.id === '定额代号') {
|
|
|
+ if(formdata3.value.sczl_jtbh === ''){
|
|
|
+ ElMessage({
|
|
|
+ type: 'error',
|
|
|
+ message: '请先选择机台!'
|
|
|
+ })
|
|
|
+ //自动聚焦光标
|
|
|
+ setTimeout(() => {
|
|
|
+ const inputElement = document.getElementById('机器');
|
|
|
+ if (inputElement) {
|
|
|
+ inputElement.focus();
|
|
|
+ }
|
|
|
+ }, 100);
|
|
|
+ }else{
|
|
|
+ FJPgetDedhsubmit();
|
|
|
+ }
|
|
|
+ }
|
|
|
let nextIndex = currentIndex + 1;
|
|
|
while (nextIndex < inputs.length) {
|
|
|
if (inputs[nextIndex].disabled) {
|