浏览代码

新增规格字段

xiaochan 2 月之前
父节点
当前提交
988abf90d8
共有 4 个文件被更改,包括 104 次插入43 次删除
  1. 24 27
      src/components/xmlr/components/FeeTableColumn.vue
  2. 16 12
      src/directives/v-cy-print.js
  3. 2 0
      src/main.js
  4. 62 4
      src/utils/cy-use/useVuePrint.tsx

+ 24 - 27
src/components/xmlr/components/FeeTableColumn.vue

@@ -1,36 +1,33 @@
-<script setup lang="ts">
-
-</script>
+<script setup lang="ts"></script>
 
 <template>
-  <el-table-column label="流水号" prop="detailSn" width="70px"/>
-  <el-table-column label="医嘱号" prop="orderNo" width="70px"/>
-  <el-table-column prop="chargeDate" label="录入日期" width="80px"/>
-  <el-table-column prop="chargeCodeMx" label="项目编码"/>
-  <el-table-column prop="chargeName" label="项目名称"/>
-  <el-table-column prop="genTime" label="执行时间" width="80px"/>
-  <el-table-column prop="execDept" label="执行科室"/>
-  <el-table-column prop="deptCode" label="申请科室"/>
-  <el-table-column prop="chargeFee" label="金额"/>
-  <el-table-column label="数量" prop="chargeAmount"/>
-  <el-table-column label="录入人" prop="opIdName"/>
-  <el-table-column label="账单码" prop="billItemName"/>
+  <el-table-column label="流水号" prop="detailSn" width="70px" />
+  <el-table-column label="医嘱号" prop="orderNo" width="70px" />
+  <el-table-column prop="chargeDate" label="录入日期" width="80px" />
+  <el-table-column prop="chargeCodeMx" label="项目编码" />
+  <el-table-column prop="chargeName" label="项目名称" />
+  <el-table-column prop="genTime" label="执行时间" width="80px" />
+  <el-table-column prop="execDept" label="执行科室" />
+  <el-table-column prop="deptCode" label="申请科室" />
+  <el-table-column prop="chargeFee" label="金额" />
+  <el-table-column label="数量" prop="chargeAmount" />
+  <el-table-column label="录入人" prop="opIdName" />
+  <el-table-column label="账单码" prop="billItemName" />
+  <el-table-column label="规格" prop="descriptions" />
   <el-table-column label="是否退费" prop="tuiFeiFlag">
     <template #default="scope">
-              <span v-if="scope.row.oriDetailSn === -1" style="color: red"
-              >已退费 <br/>
-              </span>
+      <span v-if="scope.row.oriDetailSn === -1" style="color: red"
+        >已退费 <br />
+      </span>
       <span v-if="scope.row.oriDetailSn > 0"
-      ><span style="color: #e6a23c">退费数据</span> <br/>
-                <span style="color: teal">
-                  原流水号为 <br/>
-                  【 {{ scope.row.oriDetailSn }} 】
-                </span>
-              </span>
+        ><span style="color: #e6a23c">退费数据</span> <br />
+        <span style="color: teal">
+          原流水号为 <br />
+          【 {{ scope.row.oriDetailSn }} 】
+        </span>
+      </span>
     </template>
   </el-table-column>
 </template>
 
-<style lang="scss">
-
-</style>
+<style lang="scss"></style>

+ 16 - 12
src/utils/cy-use/test.js → src/directives/v-cy-print.js

@@ -94,11 +94,9 @@ class e {
   }
 
   write(e) {
-    e.open(),
-      e.write(
-        `${this.docType()}<html>${this.getHead()}${this.getBody()}</html>`
-      ),
-      e.close();
+    e.open();
+    e.write(`${this.docType()}<html>${this.getHead()}${this.getBody()}</html>`);
+    e.close();
   }
 
   docType() {
@@ -130,13 +128,18 @@ class e {
         } catch (s) {
           console.log(l[r].href + s);
         }
-    return (
-      this.settings.extraCss &&
-        this.settings.extraCss.replace(/([^,\s]+)/g, e => {
-          t += `<link type="text/css" rel="stylesheet" href="${e}">`;
-        }),
-      `<head><title>${this.settings.popTitle}</title>${e}${t}<style type="text/css">${i}</style></head>`
-    );
+
+    this.settings.extraCss &&
+      this.settings.extraCss.replace(/([^,\s]+)/g, e => {
+        t += `<link type="text/css" rel="stylesheet" href="${e}">`;
+      });
+
+    let pageCss = "";
+    if (this.settings.extraPageCss) {
+      pageCss = `<style type="text/css">${this.settings.extraPageCss}</style>`;
+    }
+
+    return `<head><title>${this.settings.popTitle}</title>${e}${t}<style type="text/css">${i}</style>${pageCss}</head>`;
   }
 
   getBody() {
@@ -392,6 +395,7 @@ var t = {
         standard: "",
         extraHead: i.value.extraHead,
         extraCss: i.value.extraCss,
+        extraPageCss: i.value.extraPageCss || "",
         zIndex: i.value.zIndex || 20002,
         previewTitle: i.value.previewTitle || "打印预览",
         previewPrintBtnLabel: i.value.previewPrintBtnLabel || "打印",

+ 2 - 0
src/main.js

@@ -29,6 +29,7 @@ import ContextMenu from "@imengyu/vue3-context-menu";
 import VTitle from "./directives/v-title";
 import VWaves from "./directives/v-waves";
 import VElBtn from "./directives/v-el-btn";
+import VCyPrint from "@/directives/v-cy-print.js";
 
 DomZIndex.getNext = () => {
   return useZIndex().nextZIndex();
@@ -48,6 +49,7 @@ for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
 piniaInstall(app);
 app.use(ElementPlus, { locale: zhCn, size: "small" });
 app.use(DataVVue3);
+app.directive("cy-print", VCyPrint);
 app.directive("el-btn", VElBtn);
 app.directive("title", VTitle);
 app.directive("ClickOutside", ClickOutside);

+ 62 - 4
src/utils/cy-use/useVuePrint.tsx

@@ -1,12 +1,33 @@
 import { listNotBlank, stringIsBlank } from "@/utils/blank-utils";
 import { uuid } from "@/utils/getUuid";
 
+/**
+ * 如果使用了 useTable 的话,建议不要使用全局的 table 样式污染
+ * 建议 .xxxtable {
+ *   table{
+ *     asdsad
+ *   }
+ *
+ *   tr,td{
+ *     这样写
+ *   }
+ * }
+ * @param options
+ */
 export function useVuePrint(
   options: {
     id?: string;
     extraCss?: string[];
     hidden?: boolean;
     contentStyle?: StyleValue;
+    extraPageCss?: string;
+    popTitle?: string;
+    useTable?: boolean;
+    previewBeforeOpenCallback: () => void;
+    previewOpenCallback: () => void;
+    openCallback: () => void;
+    closeCallback: () => void;
+    beforeOpenCallback: () => void;
   } = {}
 ) {
   const {
@@ -15,7 +36,7 @@ export function useVuePrint(
       margin: 0,
       padding: 0,
     },
-
+    useTable = false,
     ...printOjb
   } = options;
 
@@ -41,21 +62,58 @@ export function useVuePrint(
         <div style={hidden ? { height: 0, width: 0, overflow: "hidden" } : {}}>
           <button
             style={{ display: "none" }}
-            v-print={printOjb}
+            v-cy-print={printOjb}
             ref={buttonRef}
           ></button>
           <div style={contentStyle} class="print-content" id={printOjb.id}>
-            {slots.default()}
+            {slots?.default?.()}
           </div>
         </div>
       );
     },
   });
 
+  const tableTemplate = defineComponent({
+    setup(_, { slots }) {
+      const notStyle = { margin: 0, padding: 0, border: 0 };
+
+      return () => (
+        <div style={hidden ? { height: 0, width: 0, overflow: "hidden" } : {}}>
+          <button
+            style={{ display: "none" }}
+            v-cy-print={printOjb}
+            ref={buttonRef}
+          ></button>
+          <table style={notStyle} id={printOjb.id}>
+            {slots?.header ? (
+              <thead style={notStyle}>
+                <tr style={notStyle}>
+                  <th style={notStyle}>{slots?.header?.()}</th>
+                </tr>
+              </thead>
+            ) : null}
+            <tbody style={notStyle}>
+              <tr style={notStyle}>
+                <td style={notStyle}>{slots?.default?.()}</td>
+              </tr>
+            </tbody>
+            {slots?.footer ? (
+              <tfoot style={notStyle}>
+                <tr style={notStyle}>
+                  <td style={notStyle}>{slots?.footer?.()}</td>
+                </tr>
+              </tfoot>
+            ) : null}
+          </table>
+        </div>
+      );
+    },
+  });
+
   async function print() {
     await nextTick();
     buttonRef.value.click();
   }
 
-  return [printTemplate, print, printOjb];
+  return [useTable ? tableTemplate : printTemplate, print, printOjb];
 }