You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

228 lines
8.1 KiB

7 days ago
3 days ago
7 days ago
3 days ago
7 days ago
3 days ago
7 days ago
3 days ago
7 days ago
3 days ago
7 days ago
3 days ago
7 days ago
3 days ago
7 days ago
3 days ago
7 days ago
3 days ago
7 days ago
2 days ago
7 days ago
3 days ago
7 days ago
3 days ago
7 days ago
3 days ago
2 days ago
3 days ago
7 days ago
3 days ago
7 days ago
3 days ago
7 days ago
3 days ago
7 days ago
3 days ago
7 days ago
3 days ago
7 days ago
3 days ago
7 days ago
  1. <template>
  2. <div style="display: flex;">
  3. <!-- :editor-toolbar="customToolbar" overflow-y: scroll;-->
  4. <div>
  5. <div :style="`width:${window.pageWidth - 520}px;`">
  6. <vue-editor v-model="form.informedConsentTemplateFileContent" :style="`height: ${divHeight}px;`" />
  7. </div>
  8. <div style="margin: 60px 10px 10px 0; display: flex;justify-content: space-between;">
  9. <div style="color: red;">${signMan} ${signDate} 为预设参数由具体值代替</div>
  10. <div style="display: flex;">
  11. <el-button type="primary" @click="btnInit" class="commonbutton" size="small">预置模版</el-button>
  12. <el-button type="primary" @click="btnPreview" class="commonbutton" size="small">预览</el-button>
  13. <el-button type="primary" @click="btnDesign" class="commonbutton" size="small">{{ designAble ?
  14. '设计' : '应用' }}</el-button>
  15. <el-button type="primary" @click="btnOk" class="commonbutton" size="small">确定</el-button>
  16. </div>
  17. </div>
  18. </div>
  19. <div style="width:500px;border: 1px #DCDFE6; ">
  20. <div style="display: flex;">
  21. <span style="width: 70px;margin-top: 6px;">模板名称</span>
  22. <el-input v-model="form.displayName" placeholder="模板名称" size="small"></el-input>
  23. </div>
  24. <el-input v-model="contentDesign" type="textarea" :autosize="autosize" :disabled="designAble" placeholder="源码"
  25. size="small"></el-input>
  26. </div>
  27. <!-- 模板预览 -->
  28. <el-dialog title="模板预览" :visible.sync="acceptTemplateShow" :append-to-body="true" :close-on-click-modal="false"
  29. width="900px">
  30. <div style="height: 500px;overflow:auto;" v-html="contentShow"></div>
  31. </el-dialog>
  32. </div>
  33. </template>
  34. <script>
  35. import { VueEditor, Quill } from "vue2-editor";
  36. import { mapState } from "vuex";
  37. import moment from "moment";
  38. import { postapi } from "@/api/api";
  39. const Size = Quill.import("attributors/style/size");
  40. Size.whitelist = ["12px", "14px", "16px", "18px", "24px", "32px", "48px"];
  41. Quill.register(Size, true);
  42. // 定义你需要的字体列表
  43. const fontList = [
  44. 'Microsoft-YaHei', // 微软雅黑
  45. 'SimSun', // 宋体
  46. 'SimHei', // 黑体
  47. 'KaiTi', // 楷体
  48. 'Arial',
  49. 'Times-New-Roman'
  50. ]
  51. // 获取 Quill 的字体模块,并将自定义列表设置为白名单
  52. const Font = Quill.import('formats/font')
  53. Font.whitelist = fontList
  54. // 重要:将修改后的字体模块重新注册回去
  55. Quill.register(Font, true)
  56. export default {
  57. components: { VueEditor },
  58. props: ['refParams', 'refFun'],
  59. data() {
  60. return {
  61. form: {
  62. id: '',
  63. displayName: "",
  64. informedConsentTemplateFileContent: ""
  65. },
  66. contentInit: '<h2 style="text-align:center;"><strong>CT检查知情同意书</strong></h2><p>尊敬的客户:</p><p>  欢迎您来到长城体检中心进行CT检查,在检查之前,您需要知晓以下事宜:辐射有害健康,请远离电离辐射</p><p>  1、人体受到放射线照射后,可能产生潜在的危害,产生有害的躯体效应和遗传效应,其中最敏感的器官或组织为:甲状腺、性腺、及胚胎组织。</p><p>  2、孕妇原则上禁止CT检查,如果您是孕妇,在CT检查前,请告知工作人员。</p><p>  3、如果您正处在备孕阶段,原则上我们不建议进行CT检查,请您提前告知工作人员。</p><p>  4、CT检查时只允许一名受检者进入机房,无关人员不得在机房内停留。</p><p>  5、建议受检者佩戴门诊部提供的防护用品,遮盖敏感部位。 家屋到扫描室外等候。</p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p><br></p><p style="font-size:24px;text-align:right;"><strong>受检人签名:</strong>${signMan}</p><p><br></p><p style="font-size:20px;text-align:right;padding-right:40px;">${signDate}</p>',
  67. // 自定义工具栏配置
  68. customToolbar: [
  69. // 字体大小控制(关键配置)
  70. //[{ size: ["small", false, "large", "huge"] }], // false 代表默认大小
  71. [{ size: ["12px", "14px", "16px", "18px", "24px", "32px", "48px"] }],
  72. // 字体控制(可选)
  73. //[{ font: [] }],
  74. [{ font: fontList }],
  75. // 标题控制
  76. //[{ header: [false, 1, 2, 3, 4, 5, 6] }],
  77. // 基础格式
  78. ["bold", "italic", "underline", "strike"],
  79. // 文本颜色和背景色
  80. [{ color: [] }, { background: [] }],
  81. // 文本对齐
  82. [{ align: ["", "center", "right", "justify"] }],
  83. // 列表
  84. [{ list: "ordered" }, { list: "bullet" }, { list: "check" }],
  85. // 缩进
  86. [{ indent: "-1" }, { indent: "+1" }],
  87. // 引用和代码块
  88. ["blockquote", "code-block"],
  89. // 链接、图片、视频
  90. ["link", "image", "video"],
  91. // 清除格式
  92. ["clean"]
  93. ],
  94. designAble: true,
  95. contentDesign: '',
  96. acceptTemplateShow: false, // 预览
  97. contentShow: '', // 预览
  98. };
  99. },
  100. //创建组件后
  101. created() {
  102. this.form.informedConsentTemplateFileContent = this.contentInit
  103. },
  104. //挂载组件完成
  105. mounted() {
  106. this.getAcceptTempPalte(this.refParams.id)
  107. },
  108. computed: {
  109. ...mapState(["window", "dict", "dialogWin"]),
  110. divHeight() {
  111. return this.window.pageHeight - 120
  112. },
  113. autosize() {
  114. let rows = Math.floor((this.window.pageHeight - 105 - 6) / 20)
  115. return { minRows: rows, maxRows: rows }
  116. }
  117. },
  118. // 方法
  119. methods: {
  120. getAcceptTempPalte(informedConsentTemplateId) {
  121. if (informedConsentTemplateId) {
  122. postapi('/api/app/InformedConsentTemplate/Get', { informedConsentTemplateId })
  123. .then(res => {
  124. if (res.code > -1) {
  125. this.form = res.data
  126. }
  127. })
  128. .finally(() => {
  129. this.contentDesign = this.form.informedConsentTemplateFileContent
  130. this.designAble = true
  131. })
  132. } else {
  133. this.form.id = ''
  134. this.form.displayName = ''
  135. this.btnInit()
  136. }
  137. },
  138. btnOk() {
  139. if (!this.form.displayName){
  140. this.$message.warning({ showClose: true, message: '模板名称不能为空' })
  141. return
  142. }else if(!this.form.informedConsentTemplateFileContent) {
  143. this.$message.warning({ showClose: true, message: '模板内容不能为空' })
  144. return
  145. }
  146. let url = '/api/app/InformedConsentTemplate/Create'
  147. if (this.form.id) {
  148. url = '/api/app/InformedConsentTemplate/Update'
  149. }
  150. // 保存时,刷新列表
  151. postapi(url, this.form)
  152. .then(res => {
  153. if (res.code > -1) {
  154. this.$message.success({showClose:true,message:'操作成功!'})
  155. if (!this.form.id && res.data?.id) this.form.id = res.data.id
  156. }
  157. })
  158. .finally(() => {
  159. // 刷新父主件
  160. try {
  161. this.refFun(this.form.id)
  162. } catch (error) {
  163. console.error('知情同意书模板 refFun', error)
  164. }
  165. })
  166. },
  167. btnInit() {
  168. this.form.informedConsentTemplateFileContent = this.contentInit
  169. this.contentDesign = this.contentInit
  170. this.designAble = true
  171. },
  172. // 查看效果
  173. btnPreview() {
  174. this.acceptTemplateShow = true
  175. let signMan = '<img width="100" height="50" src="/pic/egSignMan.png">'
  176. let signDate = moment(new Date()).format('yyyy 年 MM 月 DD 日')
  177. this.contentShow = this.form.informedConsentTemplateFileContent.replace('${signMan}', signMan).replace('${signDate}', signDate)
  178. },
  179. btnDesign() {
  180. if (this.designAble) {
  181. this.contentDesign = this.form.informedConsentTemplateFileContent
  182. } else {
  183. this.form.informedConsentTemplateFileContent = this.contentDesign
  184. }
  185. this.designAble = !this.designAble
  186. }
  187. },
  188. // 监听
  189. watch: {
  190. "refParams.brushTimes": {
  191. // immediate:true,
  192. handler(newVal, oldVal) {
  193. console.log(`watch 模板 newVal: ${newVal}, oldVal: ${oldVal} `, this.refParams);
  194. if (newVal != oldVal) this.getAcceptTempPalte(this.refParams.id)
  195. }
  196. },
  197. },
  198. };
  199. </script>