console
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
<script src="https://unpkg.com/vue@next"></script>
<style type="text/css">
* {
user-select: none;
font-family: fangsong;
}
html,
body,
#app {
height: 100%;
font-size: 16px;
}
table {
table-layout: fixed;
empty-cells: show;
border-collapse: collapse;
margin: 0 auto;
}
table td,
table th {
height: 2em;
width: 2em;
box-sizing: content-box;
border: 1px solid #cad9ea;
text-align: center;
}
table tr.alter th {
background: #e8f4fd;
}
table tr.alter {
background: #f5fafe;
}
td:hover {
background: #e8f4fd;
}
td.choose,
td.choose:hover {
background: #dceefb;
}
td.side , th.side{
border-right-color: rgb(122 122 122 / 41%);
border-right-width: 2px;
}
.warn {
box-shadow: inset 0 0 0.1em 0.1em red;
}
input {
outline-style: none;
border-width: 0px;
border-radius: 3px;
padding: 7px 10px;
width: calc(100% - 10px * 2);
font-size: 1rem;
background: unset;
}
.input {
font-weight: 700;
}
.input:focus {
border-color: #66afe9;
outline: 0;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, .6);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, .6)
}
.button {
cursor: pointer;
color: #7a7a7a;
}
.input::-webkit-input-placeholder {
padding-left: 5px;
font-size: 1rem;
color: #d4d7da;
}
.input::-moz-placeholder {
padding-left: 5px;
font-size: 1rem;
color: #d4d7da;
}
.input:-ms-input-placeholder {
padding-left: 5px;
font-size: 1rem;
color: #d4d7da;
}
.input:focus::-webkit-input-placeholder {
color: transparent;
}
.input:focus:-moz-placeholder {
color: transparent;
}
.input:focus::-moz-placeholder {
color: transparent;
}
.input:focus:-ms-input-placeholder {
color: transparent;
}
</style>
</head>
<body>
<div id="app">
<table class="table">
<tr class="alter">
<th v-for="item,j in title" :class="{side: title.length>>1==(j+1)}">{{item}}</th>
</tr>
<tr v-for="i in rows" class="alter">
<td @click="mouseclick((i-1)*title.length+j)"
v-for="j in title.length"
:class="{warn:title.includes(text.get((i-1)*title.length+j))&&mode_index==0, choose: choose.get((i-1)*title.length+j)!=undefined, side: title.length>>1==j}">
{{choose.get((i-1)*title.length+j)||text.get((i-1)*title.length+j)}}
</td>
</tr>
<tr class="alter">
<td :colspan="Math.round(title.length/5*4)" style="padding:0">
<input ref="input" type="text" class="input" v-model="tl" @keyup.enter="keyenter" placeholder="先选择后输入" title="回车确认" />
</td>
<td :colspan="Math.round(title.length/5)" style="padding:0">
<input type="button" class="button" :value="mode[mode_index]" @click="mode_index=mode_index*-1+1" />
</td>
</tr>
</table>
<template v-for="v,k in choose">[{{k}}]{{v[0]}}={{v[1]}},</template>
<a href="https://zhidao.baidu.com/question/2275111875408170668.html">
https://zhidao.baidu.com/question/2275111875408170668.html
</a>
</div>
<script>
const title = '翠柳迎春千里绿黄牛耕地王里金'.split('')
Vue.createApp({
watch: {
tl(val, pre) {
this.tl_arr = val.split('');
for(let i of this.choose){
let k = i[0],
v = i[1]
let c = this.tl_arr.shift()
this.choose.set(k, (c ? c : ''))
this.text.delete(k)
}
},
},
methods: {
mouseclick(i) {
if(this.choose.has(i))
this.choose.delete(i)
else{
let c = this.tl_arr.shift()
this.choose.set(i,c?c:'')
}
this.$refs.input.focus()
},
keyenter() {
for(let i of this.choose){
let k = i[0],
v = i[1]
this.text.set(k, (v ? v : ''))
}
this.tl = ''
this.choose.clear()
},
},
data() {
return {
title,
rows: 13,
tl: '',
tl_arr: [],
choose: new Map(),
text: new Map(),
mode: ['不能重复', '允许重复'],
mode_index: 0,
}
}
}).mount('#app')
</script>
</body>
</html>