支持复制常驻留言

This commit is contained in:
2022-08-22 11:07:52 +08:00
parent d897e9a33d
commit 4ef6a822c1
7 changed files with 127 additions and 21 deletions

View File

@ -0,0 +1,30 @@
import PickleComplate from "../vendor/picomplete/picomplete";
(function () {
const id_input = document.getElementById("broadcast_id")
const pickle_config = {
target: '#broadcast_select',
suggest: ["alias", "abbr"],
clickCallback: (target, node) => {
target.value = node.text;
id_input.value = node.value;
}
};
let local_data_string = window.localStorage.getItem("append_broadcast_list");
if (!local_data_string) {
return fetch("/programs/construct/append/broadcast_list", {
"method": "GET",
}).then((response) => response.json()).then((data) => {
window.localStorage.setItem("append_broadcast_list", JSON.stringify(data));
new PickleComplate({
data: data,
config: pickle_config,
})
});
} else {
new PickleComplate({
data: JSON.parse(local_data_string),
config: pickle_config,
})
}
})()

View File

@ -118,8 +118,8 @@ export default class PickleComplate {
}
containsSuggest(item, value) {
if (item.text.toLowerCase().includes(value.toLowerCase()) ||
item.value.toLowerCase().includes(value.toLowerCase())) {
if (item.text.toString().toLowerCase().includes(value.toLowerCase()) ||
item.value.toString().toLowerCase().includes(value.toLowerCase())) {
return true;
}
if (this.config.suggest) {
@ -127,7 +127,7 @@ export default class PickleComplate {
this.config.suggest = [this.config.suggest]
}
for (const suggest_key of this.config.suggest) {
if (item.hasOwnProperty(suggest_key) && item[suggest_key].toLowerCase().includes(value.toLowerCase())) {
if (item.hasOwnProperty(suggest_key) && item[suggest_key].toString().toLowerCase().includes(value.toLowerCase())) {
return true;
}
}

View File

@ -0,0 +1,26 @@
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>录播节目点播信息修改</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="{{ mix('/css/app.css') }}" rel="stylesheet"/>
<script src="{{ mix('/js/manifest.js') }}" rel="script"></script>
<link href="{{ asset('/css/vendor/picomplete/picomplete.css') }}" rel="stylesheet"/>
</head>
<body>
@include("common.header")
<form class="w-full lg:w-1/2 lg:ml-6 border-2" action="" method="post" enctype="multipart/form-data">
<label class="block my-2" id="broadcast_select">
复制的名称
<input class="form-input border-0 border-b-2 w-full" type="text" name="name" value="{{ old('name') }}">
<input class="form-input border-0 border-b-2 w-full" id="broadcast_id" type="hidden" name="id" value="{{ old('id') }}">
</label>
@include("common.form_error")
<div class="block my-2 text-center">
<input class="px-6 py-2 inline-block rounded-full bg-cyan-600 text-white" type="submit">
</div>
</form>
@include("common.footer")
</body>
<script src="{{ mix('/js/component/broadcast_select.js') }}" rel="script"></script>
</html>

View File

@ -8,6 +8,7 @@
<body>
@include("common.header")
<a href="{{route("program.construct.append.add", ["program"=>$program->id])}}">新增</a>
<a href="{{route("program.construct.append.copy", ["program"=>$program->id])}}">复制常驻留言</a>
<table class="table-auto border-collapse w-full lg:border lg:border-black">
<thead>
<tr class="border border-black sticky bg-white lg:static top-0 left-0 right-0">