MedicineInfoPg.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <el-form :rules="rules" :model="data" ref="form" class="sub-form">
  3. <!--<el-input v-model="form.orderNo" :value="index" type="hidden"></el-input>-->
  4. <!-- <el-form-item label="是否属于诊断依据:" prop="isReason" label-width="160px">
  5. <el-select v-model="data.isReason" placeholder="请选择">
  6. <el-option label="否" :value="0"></el-option>
  7. <el-option label="是" :value="1"></el-option>
  8. </el-select>
  9. </el-form-item>-->
  10. <el-form-item label="段落标题:" prop="title" label-width="160px">
  11. <el-input v-model="data.title"></el-input>
  12. </el-form-item>
  13. <el-form-item label="内容类型:" prop="position" label-width="160px">
  14. <el-checkbox-group v-model="data.position">
  15. <el-checkbox v-for="it in positions" :key="it.key" :label="it.key">{{it.name}}</el-checkbox>
  16. </el-checkbox-group>
  17. </el-form-item>
  18. <el-form-item label="内容" prop="content" label-width="160px">
  19. <quillEditor
  20. v-model="data.content"
  21. :options="editorOption"
  22. class="ql-editor"
  23. ref="quillEditor"
  24. ></quillEditor>
  25. </el-form-item>
  26. <div class="order-btn">
  27. <a v-if="index!==0" :class="index===total-1?'order-spc':'order-up'" @click="reOrder(1)">上升</a>
  28. <a v-if="index!==total-1" :class="index===0?'order-spc':'order-down'" @click="reOrder(0)">下降</a>
  29. </div>
  30. <el-form-item label-width="160px" class='btns'>
  31. <el-button @click="addEmit">添加段落</el-button>
  32. <el-button @click="delEmit" type="info">删除本段落</el-button>
  33. </el-form-item>
  34. </el-form>
  35. </template>
  36. <script>
  37. import 'quill/dist/quill.core.css';
  38. import 'quill/dist/quill.snow.css';
  39. import 'quill/dist/quill.bubble.css';
  40. import { quillEditor, Quill } from 'vue-quill-editor';
  41. import config from '@api/config';
  42. import { container, ImageExtend, QuillWatch } from 'quill-image-extend-module';
  43. Quill.register('modules/ImageExtend', ImageExtend);
  44. export default {
  45. props: ['data', 'index', 'isEdit', 'total', 'showType'],
  46. name: 'MedicineInfoParagraph',
  47. components: {
  48. quillEditor
  49. },
  50. data() {
  51. return {
  52. toolbars: [
  53. [
  54. ['bold', 'underline', 'strike'],
  55. [{ list: 'ordered' }, { list: 'bullet' }],
  56. [{ script: 'sub' }, { script: 'super' }],
  57. [{ color: [] }, { background: [] }],
  58. [{ align: [] }],
  59. ['image']
  60. ]
  61. ],
  62. toolbarMode: 0,
  63. editorOption: {
  64. modules: {
  65. ImageExtend: {
  66. loading: true,
  67. name: 'upfile',
  68. size: 1,
  69. sizeError: () => {
  70. this.$message({
  71. showClose: true,
  72. message: '请上传 1M 以内的图片!',
  73. type: 'warning'
  74. });
  75. },
  76. action: config.urls.promptServer,
  77. response: res => {
  78. if (res.code == '0') {
  79. return config.imgHost + res.data.url;
  80. } else {
  81. this.$message({
  82. showClose: true,
  83. message: res.msg,
  84. type: 'warning'
  85. });
  86. }
  87. }
  88. },
  89. toolbar: {
  90. container: container,
  91. handlers: {
  92. image: function() {
  93. QuillWatch.emit(this.quill.id);
  94. }
  95. }
  96. }
  97. }
  98. },
  99. form: {
  100. position: [],
  101. orderNo: 0
  102. },
  103. positions: [], //位置列表
  104. rules: {
  105. // isReason: [
  106. // { required: true, message: '请选择是否属于诊断', trigger: 'change' }
  107. // ],
  108. position: [
  109. { required: true, message: '请选择显示位置', trigger: 'change' }
  110. ],
  111. title: [
  112. { required: true, message: '请输入标题名称', trigger: 'change' },
  113. {
  114. validator: (rule, value, callback) => {
  115. if (value.length > 30) {
  116. callback(new Error('标题名称不能超过30字'));
  117. } else {
  118. callback();
  119. }
  120. },
  121. trigger: 'change'
  122. }
  123. ],
  124. content: [
  125. { required: true, message: '请输入段落内容', trigger: 'change' }
  126. ]
  127. }
  128. };
  129. },
  130. watch: {
  131. 'data.content': function() {
  132. this.data.text = this.$refs.quillEditor.quill.root.innerText;
  133. }
  134. },
  135. created() {
  136. console.log(this.showType, 'showType');
  137. this.editorOption.modules.toolbar.container = this.toolbars[
  138. this.toolbarMode
  139. ];
  140. },
  141. mounted() {
  142. //显示位置枚举列表
  143. const pos = localStorage.getItem('knowledgeEnumsData');
  144. let positions = config.contentTypes;
  145. if (this.showType == 1) {
  146. // 诊断
  147. this.positions = positions.filter(item => item.key !== 2);
  148. } else if (
  149. this.showType == 3 ||
  150. this.showType == 4 ||
  151. this.showType == 5
  152. ) {
  153. // 检验/检查
  154. this.positions = positions.filter(item => {
  155. return item.key <= 2
  156. });
  157. } else if (this.showType == 2 || this.showType == 6) {
  158. // 药品/手术
  159. this.positions = positions.filter(item => item.key === 1);
  160. } else {
  161. this.positions = positions;
  162. }
  163. },
  164. methods: {
  165. reOrder(i) {
  166. this.$emit('reOrder', i, this.index);
  167. },
  168. addEmit() {
  169. this.$emit('add');
  170. },
  171. delEmit() {
  172. this.$emit('del', this.index);
  173. }
  174. /*emitVal(){
  175. let data = this.form;
  176. let pst=this.form.position;
  177. const content = this.form.content.replace(config.imgHost,'{imageUrlPrefix}');
  178. const text = this.$refs.quillEditor;console.log(text)
  179. pst = typeof pst=='string'?pst:pst.join(',');
  180. data = Object.assign({},data,{
  181. position:this.form.position?pst:'',
  182. orderNo:this.index,
  183. text:'',
  184. content:content});
  185. this.$emit("change",this.index,data);
  186. }*/
  187. }
  188. };
  189. </script>
  190. <style lang="less">
  191. .quill-editor.ql-editor {
  192. padding-left: 0 !important;
  193. }
  194. .is-error .el-form-item__error {
  195. top: auto;
  196. }
  197. .sub-form {
  198. position: relative;
  199. }
  200. .order-btn {
  201. position: absolute;
  202. top: 12px;
  203. right: 0;
  204. a {
  205. margin-bottom: 20px;
  206. border: 1px solid #22ccc8;
  207. color: #22ccc8;
  208. padding: 5px 10px;
  209. border-radius: 4px;
  210. cursor: pointer;
  211. font-size: 12px;
  212. }
  213. .order-spc {
  214. margin-top: 28px;
  215. }
  216. .order-down {
  217. margin-left: 20px;
  218. }
  219. }
  220. /**富文本编辑器样式修改***/
  221. .ql-snow .ql-picker.ql-size .ql-picker-label::before,
  222. .ql-snow .ql-picker.ql-size .ql-picker-item::before,
  223. .ql-snow .ql-picker.ql-header .ql-picker-label::before,
  224. .ql-snow .ql-picker.ql-header .ql-picker-item::before,
  225. .ql-snow .ql-picker.ql-font .ql-picker-label::before,
  226. .ql-snow .ql-picker.ql-font .ql-picker-item::before,
  227. .ql-snow .ql-color-picker .ql-picker-label svg,
  228. .ql-snow .ql-icon-picker .ql-picker-label svg {
  229. vertical-align: top;
  230. }
  231. .btns{
  232. margin-top: 24px;
  233. }
  234. </style>