|
@@ -1,5 +1,6 @@
|
|
|
<template>
|
|
|
- <fs-page class="borrow-page">
|
|
|
+ <!-- <fs-page class="borrow-page"> -->
|
|
|
+ <fs-page>
|
|
|
<fs-crud ref="crudRef" v-bind="crudBinding" />
|
|
|
<BorrowTypeSelect v-model:visible="showBorrowTypeDialog" @select="onBorrowTypeSelected" />
|
|
|
<CommonBorrow
|
|
@@ -48,8 +49,6 @@ const showSettlementDialog = ref(false);
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
const lastFormSnapshot = ref({});
|
|
|
// provide('lastFormSnapshot', lastFormSnapshot);
|
|
|
|
|
@@ -151,7 +150,7 @@ async function handleSettlement(e: CustomEvent) {
|
|
|
borrowForm.value = { ...row, mode: 'settlement' };
|
|
|
});
|
|
|
}
|
|
|
-let observer: MutationObserver | null = null;
|
|
|
+// let observer: MutationObserver | null = null;
|
|
|
|
|
|
onMounted(() => {
|
|
|
// 设置列权限
|
|
@@ -160,40 +159,55 @@ onMounted(() => {
|
|
|
// resetCrudOptions(newOptions);
|
|
|
// 刷新
|
|
|
crudExpose.doRefresh();
|
|
|
+ window.addEventListener('borrow-add', () => {
|
|
|
+ showBorrowTypeDialog.value = true
|
|
|
+ });
|
|
|
window.addEventListener('borrow-view', handleView);
|
|
|
window.addEventListener('borrow-edit', handleEdit);
|
|
|
window.addEventListener('borrow-remove', handleRemove);
|
|
|
window.addEventListener('borrow-collect', handleCollect);
|
|
|
window.addEventListener('borrow-return', handleReturn);
|
|
|
window.addEventListener('borrow-settlement', handleSettlement);
|
|
|
- // 创建借用单按钮
|
|
|
- function insertButton() {
|
|
|
- const fsActionbar = document.querySelector('.borrow-page .fs-actionbar');
|
|
|
- if (fsActionbar && !fsActionbar.querySelector('.my-create-btn')) {
|
|
|
- const button = document.createElement('button');
|
|
|
- button.className = 'el-button el-button--primary el-button--default my-create-btn';
|
|
|
- button.innerHTML = '创建借用单';
|
|
|
- button.onclick = () => {
|
|
|
- showBorrowTypeDialog.value = true;
|
|
|
- };
|
|
|
- fsActionbar.append(button);
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+ // const fsActionbar = document.querySelector('.borrow-page .fs-actionbar');
|
|
|
+ // if (!fsActionbar) return;
|
|
|
+ // // 创建借用单按钮
|
|
|
+ // function insertButton() {
|
|
|
+ // if (fsActionbar && !fsActionbar.querySelector('.my-create-btn')) {
|
|
|
+ // const button = document.createElement('button');
|
|
|
+ // button.className = 'el-button el-button--primary el-button--default my-create-btn';
|
|
|
+ // button.innerHTML = '创建借用单';
|
|
|
+ // button.onclick = () => {
|
|
|
+ // showBorrowTypeDialog.value = true;
|
|
|
+ // };
|
|
|
+ // fsActionbar.append(button);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
|
|
|
// 先尝试插入一次
|
|
|
// insertButton();
|
|
|
|
|
|
// 监听 DOM 变化,确保 actionbar 出现时插入按钮
|
|
|
- observer = new MutationObserver(() => {
|
|
|
- insertButton();
|
|
|
- });
|
|
|
- observer.observe(document.body, { childList: true, subtree: true });
|
|
|
+ // observer = new MutationObserver(() => {
|
|
|
+ // insertButton();
|
|
|
+ // });
|
|
|
+ // observer.observe(document.body, { childList: true, subtree: true });
|
|
|
+
|
|
|
+ // const observer = new MutationObserver((_m, obs) => {
|
|
|
+ // insertButton();
|
|
|
+ // // 插入完毕后停掉 observer
|
|
|
+ // obs.disconnect();
|
|
|
+ // });
|
|
|
+ // observer.observe(fsActionbar, { childList: true });
|
|
|
+
|
|
|
+
|
|
|
});
|
|
|
onBeforeUnmount(() => {
|
|
|
- if (observer) {
|
|
|
- observer.disconnect();
|
|
|
- observer = null;
|
|
|
- }
|
|
|
+ // if (observer) {
|
|
|
+ // observer.disconnect();
|
|
|
+ // observer = null;
|
|
|
+ // }
|
|
|
window.removeEventListener('borrow-view', handleView);
|
|
|
window.removeEventListener('borrow-collect', handleCollect);
|
|
|
window.removeEventListener('borrow-return', handleReturn);
|