|
@@ -144,13 +144,26 @@
|
|
|
:template-type="templateType"
|
|
|
@modified="getList"
|
|
|
></modify-template>
|
|
|
+ <!-- template-detail -->
|
|
|
+ <el-dialog
|
|
|
+ :visible.sync="templateDetailDialogIsShow"
|
|
|
+ title="印品模板"
|
|
|
+ width="1200px"
|
|
|
+ top="10px"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ :close-on-press-escape="false"
|
|
|
+ append-to-body
|
|
|
+ >
|
|
|
+ <div id="template-frame"></div>
|
|
|
+ <div slot="footer"></div>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import { ABLE_TYPE, TEMPLATE_TYPE } from "@/constants/enumerate";
|
|
|
import pickerOptions from "@/constants/datePickerOptions";
|
|
|
-import { templateListPage, ableTemplate } from "../api";
|
|
|
+import { templateListPage, ableTemplate, templateContentView } from "../api";
|
|
|
import ModifyTemplate from "../components/ModifyTemplate";
|
|
|
|
|
|
export default {
|
|
@@ -182,6 +195,7 @@ export default {
|
|
|
curTemplate: {},
|
|
|
editType: "ADD",
|
|
|
ABLE_TYPE,
|
|
|
+ templateDetailDialogIsShow: false,
|
|
|
// date-picker
|
|
|
createTime: [],
|
|
|
pickerOptions
|
|
@@ -222,10 +236,45 @@ export default {
|
|
|
this.editType = "EDIT";
|
|
|
this.$refs.ModifyTemplate.open();
|
|
|
},
|
|
|
- toDetail(row) {
|
|
|
- this.curTemplate = { ...row, type: this.templateType };
|
|
|
- this.editType = "PREVIEW";
|
|
|
- this.$refs.ModifyTemplate.open();
|
|
|
+ async toDetail(row) {
|
|
|
+ if (this.templateType === "GENERIC") {
|
|
|
+ window.open(
|
|
|
+ this.getRouterPath({
|
|
|
+ name: "CardPreview",
|
|
|
+ params: {
|
|
|
+ cardId: row.cardId,
|
|
|
+ viewType: "view"
|
|
|
+ }
|
|
|
+ })
|
|
|
+ );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const content = await templateContentView(row.attachmentId);
|
|
|
+ if (!content) return;
|
|
|
+
|
|
|
+ this.templateDetailDialogIsShow = true;
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.initFrame(content);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ initFrame(htmlContent) {
|
|
|
+ // 移除framemark标签
|
|
|
+ // htmlContent = htmlContent
|
|
|
+ // .replace(/\$\{.+?\}/g, "")
|
|
|
+ // .replace(/<#.+?>/g, "")
|
|
|
+ // .replace(/<\/#.+?>/g, "");
|
|
|
+ const frameContainerDom = document.getElementById("template-frame");
|
|
|
+ frameContainerDom.innerHTML = "";
|
|
|
+ const iframeDom = document.createElement("iframe");
|
|
|
+ frameContainerDom.appendChild(iframeDom);
|
|
|
+ console.dir(frameContainerDom);
|
|
|
+ const wwidth = frameContainerDom.parentNode.clientWidth - 50;
|
|
|
+ const wheight = window.innerHeight - 130;
|
|
|
+ iframeDom.style.cssText = `width: ${wwidth}px;height: ${wheight}px;border:none;outline:none;background-color: #fff;`;
|
|
|
+ const iframeDoc = iframeDom.contentDocument;
|
|
|
+ iframeDoc.open();
|
|
|
+ iframeDoc.write(htmlContent);
|
|
|
+ iframeDoc.close();
|
|
|
},
|
|
|
toEnable(row) {
|
|
|
const action = row.enable ? "禁用" : "启用";
|