根据股票代码快速填充股票名字
This commit is contained in:
parent
083dda7118
commit
9696657ecc
@ -10,8 +10,7 @@
|
|||||||
<cargoProject FILE="$PROJECT_DIR$/bookkeeper/Cargo.toml" />
|
<cargoProject FILE="$PROJECT_DIR$/bookkeeper/Cargo.toml" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="76b3b902-7a5c-4bcd-9c1b-8241d748fb44" name="更改" comment="bug fix: zero division error">
|
<list default="true" id="76b3b902-7a5c-4bcd-9c1b-8241d748fb44" name="更改" comment="增加快速记录功能">
|
||||||
<change afterPath="$PROJECT_DIR$/bookkeeper/templates/ftx.html.j2" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/bookkeeper/src/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/bookkeeper/src/main.rs" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/bookkeeper/src/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/bookkeeper/src/main.rs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/bookkeeper/templates/index.html.j2" beforeDir="false" afterPath="$PROJECT_DIR$/bookkeeper/templates/index.html.j2" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/bookkeeper/templates/index.html.j2" beforeDir="false" afterPath="$PROJECT_DIR$/bookkeeper/templates/index.html.j2" afterDir="false" />
|
||||||
@ -53,6 +52,7 @@
|
|||||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||||
"Cargo.Run bookkeeper.executor": "Run",
|
"Cargo.Run bookkeeper.executor": "Run",
|
||||||
"DefaultHtmlFileTemplate": "HTML File",
|
"DefaultHtmlFileTemplate": "HTML File",
|
||||||
|
"PowerShell.deploy.ps1.executor": "Run",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.git.unshallow": "true",
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
"RunOnceActivity.rust.reset.selective.auto.import": "true",
|
"RunOnceActivity.rust.reset.selective.auto.import": "true",
|
||||||
@ -133,6 +133,15 @@
|
|||||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
<configuration name="deploy.ps1" type="PowerShellRunType" factoryName="PowerShell" temporary="true" scriptUrl="$PROJECT_DIR$/bookkeeper/deploy.ps1" executablePath="C:/Program Files/PowerShell/7/pwsh.exe">
|
||||||
|
<envs />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<recent_temporary>
|
||||||
|
<list>
|
||||||
|
<item itemvalue="PowerShell.deploy.ps1" />
|
||||||
|
</list>
|
||||||
|
</recent_temporary>
|
||||||
</component>
|
</component>
|
||||||
<component name="RustProjectSettings">
|
<component name="RustProjectSettings">
|
||||||
<option name="toolchainHomeDirectory" value="$USER_HOME$/.cargo/bin" />
|
<option name="toolchainHomeDirectory" value="$USER_HOME$/.cargo/bin" />
|
||||||
@ -158,7 +167,9 @@
|
|||||||
<workItem from="1739197188908" duration="1873000" />
|
<workItem from="1739197188908" duration="1873000" />
|
||||||
<workItem from="1740209396270" duration="6333000" />
|
<workItem from="1740209396270" duration="6333000" />
|
||||||
<workItem from="1741527809947" duration="5732000" />
|
<workItem from="1741527809947" duration="5732000" />
|
||||||
<workItem from="1741617416981" duration="867000" />
|
<workItem from="1741617416981" duration="2272000" />
|
||||||
|
<workItem from="1744534517424" duration="144000" />
|
||||||
|
<workItem from="1744534680689" duration="862000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="Add bookkeeper">
|
<task id="LOCAL-00001" summary="Add bookkeeper">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
@ -288,7 +299,15 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1740216327515</updated>
|
<updated>1740216327515</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="17" />
|
<task id="LOCAL-00017" summary="增加快速记录功能">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1741618500678</created>
|
||||||
|
<option name="number" value="00017" />
|
||||||
|
<option name="presentableId" value="LOCAL-00017" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1741618500678</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="18" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
@ -322,7 +341,8 @@
|
|||||||
<MESSAGE value="添加总计" />
|
<MESSAGE value="添加总计" />
|
||||||
<MESSAGE value="添加登录页面" />
|
<MESSAGE value="添加登录页面" />
|
||||||
<MESSAGE value="bug fix: zero division error" />
|
<MESSAGE value="bug fix: zero division error" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="bug fix: zero division error" />
|
<MESSAGE value="增加快速记录功能" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="增加快速记录功能" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XSLT-Support.FileAssociations.UIState">
|
<component name="XSLT-Support.FileAssociations.UIState">
|
||||||
<expand />
|
<expand />
|
||||||
|
|||||||
2
bookkeeper/Cargo.lock
generated
2
bookkeeper/Cargo.lock
generated
@ -481,7 +481,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bookkeeper"
|
name = "bookkeeper"
|
||||||
version = "0.3.0"
|
version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bcrypt",
|
"bcrypt",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "bookkeeper"
|
name = "bookkeeper"
|
||||||
version = "0.3.0"
|
version = "0.4.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@ -538,6 +538,25 @@ fn translate(trans: Form<TransModel>) -> transaction::ActiveModel {
|
|||||||
record
|
record
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[get("/stock/<id>")]
|
||||||
|
async fn get_stock(
|
||||||
|
conn: Connection<'_, Db>,
|
||||||
|
id: i32,
|
||||||
|
cookies: &CookieJar<'_>,
|
||||||
|
) -> Result<String, Status> {
|
||||||
|
if !verify(cookies) {
|
||||||
|
return Err(Status::Forbidden);
|
||||||
|
}
|
||||||
|
let row = TE::find()
|
||||||
|
.filter(transaction::Column::Code.eq(id))
|
||||||
|
.one(conn.into_inner()).await.unwrap();
|
||||||
|
match row {
|
||||||
|
None => Ok(String::from("")),
|
||||||
|
Some(row) => Ok(row.name),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async fn run_migrations(rocket: Rocket<Build>) -> fairing::Result {
|
async fn run_migrations(rocket: Rocket<Build>) -> fairing::Result {
|
||||||
let conn = &Db::fetch(&rocket).unwrap().conn;
|
let conn = &Db::fetch(&rocket).unwrap().conn;
|
||||||
let _ = migration::Migrator::up(conn, None).await;
|
let _ = migration::Migrator::up(conn, None).await;
|
||||||
@ -565,7 +584,7 @@ async fn rocket() -> _ {
|
|||||||
"/",
|
"/",
|
||||||
routes![
|
routes![
|
||||||
index, add, get_add, get_tx, post_tx, delete_tx, login_page, login_post, post_ftx,
|
index, add, get_add, get_tx, post_tx, delete_tx, login_page, login_post, post_ftx,
|
||||||
get_ftx
|
get_ftx, get_stock
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.mount("/static", FileServer::from("static"))
|
.mount("/static", FileServer::from("static"))
|
||||||
|
|||||||
@ -130,6 +130,7 @@
|
|||||||
}
|
}
|
||||||
document.getElementById('modal-content').innerHTML = await response.text();
|
document.getElementById('modal-content').innerHTML = await response.text();
|
||||||
openModal($target);
|
openModal($target);
|
||||||
|
injectCodeEvent();
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('ftx').addEventListener('click', async () => {
|
document.getElementById('ftx').addEventListener('click', async () => {
|
||||||
@ -140,6 +141,7 @@
|
|||||||
}
|
}
|
||||||
document.getElementById('modal-content').innerHTML = await response.text();
|
document.getElementById('modal-content').innerHTML = await response.text();
|
||||||
openModal($target);
|
openModal($target);
|
||||||
|
injectCodeEvent();
|
||||||
});
|
});
|
||||||
|
|
||||||
(document.querySelectorAll('.modify-row') || []).forEach(($cl) => {
|
(document.querySelectorAll('.modify-row') || []).forEach(($cl) => {
|
||||||
@ -209,6 +211,20 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function injectCodeEvent() {
|
||||||
|
const $target = document.getElementById('code');
|
||||||
|
$target.addEventListener('blur', (event) => {
|
||||||
|
fetch(`/stock/${$target.value}`).then((resp) => {
|
||||||
|
return resp.text();
|
||||||
|
}).then((text) => {
|
||||||
|
if (text.trim().length > 0) {
|
||||||
|
const $update = document.getElementById('name');
|
||||||
|
$update.value = text;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user