AddDevKnow.vue 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291
  1. <template>
  2. <el-scrollbar style="height: 100%" ref="elscrollbar" id="message-container">
  3. <div class="NoiseTemplateWrapper TemplateWrapper knowledgeWrapper">
  4. <crumbs
  5. :title="'静态信息维护-' + title"
  6. class="topBack"
  7. :param="$route.params"
  8. linkTo="StaticInfo"
  9. ></crumbs>
  10. <div class="info-container">
  11. <el-form :rules="rules1" :model="form" label-width="160px" ref="groups1" size="mini">
  12. <div class="container_top">
  13. <div v-if="!isEdit" style="margin-right: 40px">
  14. <el-form-item label="选择标准术语:" prop="selectedTerm">
  15. <el-select
  16. v-model="form.selectedTerm"
  17. filterable
  18. remote
  19. clearable
  20. :loading="showDrop"
  21. loading-text="加载中..."
  22. @change="changeWord"
  23. @visible-change="handleVisible"
  24. value-key="id"
  25. @clear="handleClear"
  26. ref="termName"
  27. placeholder="搜索"
  28. :remote-method="searchTerms"
  29. >
  30. <el-option
  31. v-for="(term, idx) in terms"
  32. :key="idx"
  33. :label="
  34. term.name +
  35. (term.typeName ? '(' + term.typeName + ')' : '')
  36. "
  37. :value="term"
  38. :title="
  39. term.name +
  40. (term.typeName ? '(' + term.typeName + ')' : '')
  41. "
  42. ></el-option>
  43. </el-select>
  44. </el-form-item>
  45. </div>
  46. <el-form-item label="已选择标准术语:" label-width="160px">
  47. {{
  48. form.selectedTermName
  49. }}
  50. </el-form-item>
  51. </div>
  52. </el-form>
  53. <div class="tabs_box">
  54. <div class="tabs">
  55. <div
  56. class="tabs_pane"
  57. :style="
  58. tabActive == 'one'
  59. ? { color: '#fff', background: '#00c7da' }
  60. : ''
  61. "
  62. @click="tabActiveChange('one')"
  63. v-if="staticTabShow"
  64. >
  65. 静态信息
  66. <img
  67. @click.stop="handleStaticTab"
  68. src="@/images/tab_add.png"
  69. alt
  70. v-if="AssesComSHow && !AssesTabSHow"
  71. />
  72. <img
  73. v-if="AssesTabSHow && AssesComSHow"
  74. @click.stop="closeStaticTab"
  75. src="@/images/tab_close.png"
  76. alt
  77. />
  78. </div>
  79. <div
  80. class="tabs_pane"
  81. :style="
  82. tabActive == 'two'
  83. ? { color: '#fff', background: '#00c7da' }
  84. : ''
  85. "
  86. @click="tabActiveChange('two')"
  87. v-if="AssesTabSHow && AssesComSHow"
  88. >
  89. 评估内容
  90. <img
  91. v-if="!staticTabShow"
  92. @click.stop="handleAssesTab"
  93. src="@/images/tab_add.png"
  94. alt
  95. />
  96. <img
  97. v-if="staticTabShow"
  98. @click.stop="closeAssesTab"
  99. src="@/images/tab_close.png"
  100. alt
  101. />
  102. </div>
  103. </div>
  104. </div>
  105. <p class="line"></p>
  106. <div class="tab_box_left" v-show="tabActive == 'one'" v-if="staticTabShow">
  107. <el-form :rules="rules" :model="form" label-width="160px" ref="groups" size="mini">
  108. <div
  109. v-if="
  110. form.selectedTerm &&
  111. (form.typeId == 1 ||
  112. form.typeId == 3 ||
  113. form.typeId == 4 ||
  114. form.typeId == 5 ||
  115. form.typeId == 6)
  116. "
  117. >
  118. <el-form-item
  119. :label="titleChange"
  120. prop="titleChange"
  121. label-width="160px"
  122. style="margin-bottom: 20px"
  123. >
  124. <el-input v-model="form.titleChange"></el-input>
  125. </el-form-item>
  126. </div>
  127. <div v-if="!upload">
  128. <DevInfo
  129. v-for="(f, i) in form.prags"
  130. :key="(i + 1) * 10000 + showType"
  131. :data="f"
  132. :index="i"
  133. :total="form.prags.length"
  134. :isEdit="isEdit"
  135. :isCopy="isCopy"
  136. ref="subForm"
  137. @add="addParagraph(i)"
  138. @del="delParagraph"
  139. @reOrder="reOrder"
  140. :showType="showType"
  141. ></DevInfo>
  142. </div>
  143. <div v-if="upload">
  144. <el-form-item label="标题名称搜索:" prop="fileTitle" label-width="160px">
  145. <el-input v-model="form.fileTitle"></el-input>
  146. </el-form-item>
  147. </div>
  148. <div>
  149. <el-form-item
  150. v-if="upload"
  151. label="上传文件:"
  152. ref="upload"
  153. prop="fileList"
  154. label-width="160px"
  155. >
  156. <el-upload
  157. @mouseenter.native="handleMouseenter"
  158. @mouseleave.native="handleMouseleave"
  159. class="upload-demo"
  160. :action="config.urls.promptServer"
  161. name="upfile"
  162. :multiple="false"
  163. :limit="1"
  164. :on-preview="handlePreview"
  165. :on-remove="handleRemove"
  166. :before-upload="handleBeforeUpLoad"
  167. :before-remove="beforeRemove"
  168. :on-change="handleChange"
  169. :on-success="handleSuccess"
  170. :show-file-list="showFileList"
  171. :file-list="form.fileList"
  172. >
  173. <el-button size="small" type="primary" v-if="showUpLoad">点击上传</el-button>
  174. <!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div> -->
  175. </el-upload>
  176. <span class="tipInfo" v-show="isShowTip">
  177. {{
  178. form.fileList[0] && form.fileList[0].name
  179. }}
  180. </span>
  181. <!-- <el-button size="small" type="primary" >点击上传</el-button> -->
  182. </el-form-item>
  183. </div>
  184. <el-form-item label-width="160px">
  185. <div class="uploadInfo" v-if="isSuccessUpload === 1">文件上传中,请稍等...</div>
  186. </el-form-item>
  187. </el-form>
  188. </div>
  189. <div v-if="AssesComSHow && AssesTabSHow" v-show="tabActive == 'two'">
  190. <AddAssess @scrollTo="scrollTo" :childScaleData="scaleData" ref="assessRef" />
  191. </div>
  192. </div>
  193. <div class="btn">
  194. <el-button type="primary" :disabled="saveDisable" @click="submitForm">确 定</el-button>
  195. </div>
  196. </div>
  197. </el-scrollbar>
  198. </template>
  199. <script>
  200. /**
  201. *
  202. */
  203. import api from '@api/knowledgeTree.js';
  204. import DevInfo from './DevInfo';
  205. import config from '@api/config';
  206. import $ from 'jquery';
  207. import AddAssess from './AddAssess';
  208. export default {
  209. name: 'AddDevKnow',
  210. components: {
  211. DevInfo,
  212. AddAssess
  213. },
  214. data() {
  215. return {
  216. staticTabShow: true,
  217. AssesTabSHow: true,
  218. staticComShow: true,
  219. AssesComSHow: false,
  220. toAssesTermId: null,
  221. scaleData: null,
  222. isFixedTop: true,
  223. isEdit: false,
  224. isCopy: false,
  225. title: '添加',
  226. termTypes: [],
  227. terms: [], //术语列表
  228. form: {
  229. conceptId: '', //术语id
  230. isTip: 0, //是否要覆盖,0不覆盖,1覆盖
  231. selectedTerm: '', //术语标签
  232. termType: '',
  233. typeId: '',
  234. selectedTermName: '',
  235. selectedTermType: '',
  236. // titleChange: '',
  237. fileList: [],
  238. name: '',
  239. prags: [
  240. {
  241. //单个段落相关
  242. title: '',
  243. content: '',
  244. isReason: 0,
  245. orderNo: 0,
  246. position: [],
  247. text: ''
  248. }
  249. ],
  250. fileTitle: '',
  251. titleChange: ''
  252. },
  253. rules1: {
  254. selectedTerm: [
  255. { required: true, message: '请选择标准术语', trigger: 'change' }
  256. ]
  257. },
  258. rules: {
  259. fileTitle: [
  260. { required: true, message: '请输入标题名称', trigger: 'change' },
  261. {
  262. validator: (rule, value, callback) => {
  263. if (value.trim().length > 30) {
  264. callback(new Error('标题名称不能超过30字'));
  265. } else {
  266. callback();
  267. }
  268. },
  269. trigger: 'change'
  270. }
  271. ],
  272. fileList: [
  273. { required: true, message: '请上传文件', trigger: 'change' }
  274. ],
  275. titleChange: [
  276. // {
  277. // validator: (rule, value, callback) => {
  278. // if (!value.trim()) {
  279. // callback(
  280. // new Error('请输入' + this.titleChange.replace(':', ''))
  281. // );
  282. // } else {
  283. // callback();
  284. // }
  285. // },
  286. // trigger: 'change'
  287. // },
  288. { max: 30, message: '标题最多30字', trigger: 'change' }
  289. ]
  290. },
  291. saveDisable: false, //保存按钮禁止点击
  292. showDrop: false, //下拉框显示文字bug1774
  293. config: config,
  294. showUpLoad: true,
  295. showFileList: false,
  296. upload: false,
  297. showConfirm: true,
  298. isSuccessUpload: 0, //是否上传成功 0: 不在上传 1: 上传过程中 2: 上传成功
  299. isShowTip: false,
  300. showType: -1, // 1 诊断 2 药品 3检验套餐 4检验细项 5检查 6检查子 7手术和操作 8量表
  301. editCount: -1, // 页面会否被编辑 >0被编辑 =0 未编辑
  302. startCount: -1,
  303. isSaveSuccess: false, // 是否保存成功
  304. tabActive: 'one'
  305. };
  306. },
  307. watch: {
  308. showType: {
  309. handler(newVal, oldVal) {
  310. if (newVal !== oldVal) {
  311. this.form.prags = this.form.prags.map(item => {
  312. return { ...item, position: [] };
  313. });
  314. }
  315. }
  316. },
  317. form: {
  318. handler(newName, oldName) {
  319. this.editCount++;
  320. },
  321. deep: true,
  322. immediate: true
  323. }
  324. },
  325. created: function() {
  326. const { isEdit, data, isCopy } = this.$route.params;
  327. if (isEdit || isCopy) {
  328. const loading = this.$loading({
  329. lock: true,
  330. text: 'Loading',
  331. spinner: 'el-icon-loading',
  332. background: 'rgba(0, 0, 0, 0.7)'
  333. });
  334. this.showType = data.type; // 编辑页确认显示类型
  335. this.isEdit = isEdit;
  336. this.isCopy = isCopy;
  337. this.title = isEdit ? '修改' : isCopy ? '复制' : '添加';
  338. (isEdit || isCopy) && this.changeWord(data);
  339. api
  340. .getBaseRecordById({ id: data.id })
  341. .then(res => {
  342. if (res.data.code == '0') {
  343. const data = res.data.data;
  344. console.log('dwadfesvgeosboau13131213h', data.scale);
  345. if (data.type === 8) {
  346. this.AssesComSHow = true;
  347. if (data.scale) {
  348. this.scaleData = data.scale;
  349. this.AssesTabSHow = true;
  350. } else {
  351. this.AssesTabSHow = false;
  352. }
  353. }
  354. if (this.form.typeId === 82 || this.form.typeId === 83) {
  355. // console.log('data',data)
  356. this.form.fileList =
  357. data &&
  358. data.map(it => {
  359. return JSON.parse(it.content);
  360. });
  361. this.showFileList = true;
  362. this.showUpLoad = false;
  363. } else {
  364. this.conceptId = data.id;
  365. this.form.typeId = data.type;
  366. this.form.name = data.name;
  367. this.form.titleChange =
  368. data.type == 1
  369. ? data.clinicalPathwayName
  370. : data.type == 3 ||
  371. data.type == 4 ||
  372. data.type == 5 ||
  373. data.type == 6
  374. ? data.noticeName
  375. : '';
  376. this.form.selectedTermName =
  377. data.name + (data.typeName ? '(' + data.typeName + ')' : '');
  378. this.form.selectedTerm =
  379. data.name + (data.typeName ? '(' + data.typeName + ')' : '');
  380. if (isCopy) {
  381. this.handleClear();
  382. }
  383. if (data.details.length) {
  384. this.form.prags =
  385. data &&
  386. data.details.map(it => {
  387. return {
  388. title: it.title,
  389. position: it.contentType?it.contentType.split(","):[],
  390. content: it.content.replace(
  391. /{imageUrlPrefix}/g,
  392. config.imgHost
  393. ),
  394. // isReason:it.isReason,
  395. text: it.text,
  396. disabled: true
  397. };
  398. });
  399. } else {
  400. this.staticTabShow = false;
  401. this.tabActiveChange('two');
  402. }
  403. }
  404. }
  405. setTimeout(() => {
  406. loading.close();
  407. }, 200);
  408. })
  409. .catch(error => {
  410. loading.close();
  411. if (error.code === '900010001') {
  412. return false;
  413. }
  414. console.log(error);
  415. });
  416. }
  417. setTimeout(() => {
  418. this.startCount = this.editCount;
  419. }, 500);
  420. },
  421. mounted() {},
  422. beforeRouteLeave(to, from, next) {
  423. // if (this.isSuccessUpload === 1) {
  424. // this.$confirm('文件正在上传,是否确定返回?', '提示', {
  425. // confirmButtonText: '确定',
  426. // cancelButtonText: '取消',
  427. // cancelButtonClass: 'cancel',
  428. // type: 'warning'
  429. // })
  430. // .then(() => {
  431. // next();
  432. // })
  433. // .catch(() => {});
  434. // // this.warning('还有未保存的文件,是否确定返回?');
  435. // } else if (this.isSuccessUpload === 2) {
  436. // this.$confirm('还有未保存的文件,是否确定返回?', '提示', {
  437. // confirmButtonText: '确定',
  438. // cancelButtonText: '取消',
  439. // cancelButtonClass: 'cancel',
  440. // type: 'warning'
  441. // })
  442. // .then(() => {
  443. // next();
  444. // })
  445. // .catch(() => {});
  446. // } else {
  447. // next();
  448. // }
  449. if (this.startCount !== this.editCount && !this.isSaveSuccess) {
  450. this.$alert('还有未保存的内容,确定要退出当前页面吗?', '提示', {
  451. confirmButtonText: '确定',
  452. // cancelButtonText: '取消',
  453. // cancelButtonClass: 'leaveBtn',
  454. // customClass: 'leaveBox',
  455. type: 'warning'
  456. })
  457. .then(() => {
  458. next();
  459. })
  460. .catch(() => {});
  461. } else {
  462. next();
  463. }
  464. },
  465. methods: {
  466. scrollTo(dom) {
  467. var div = this.$refs['elscrollbar'].$refs['wrap'];
  468. if (dom >= 0) {
  469. div.scrollTop += dom - 120;
  470. } else {
  471. div.scrollTop -= Math.abs(dom) + 120;
  472. }
  473. },
  474. handleStaticTab() {
  475. this.AssesTabSHow = true;
  476. this.AssesComSHow = true;
  477. this.tabActiveChange('two');
  478. },
  479. handleAssesTab() {
  480. this.staticTabShow = true;
  481. this.form.prags = [
  482. {
  483. //单个段落相关
  484. title: '',
  485. content: '',
  486. isReason: 0,
  487. orderNo: 0,
  488. position: [],
  489. text: ''
  490. }
  491. ];
  492. this.tabActiveChange('one');
  493. },
  494. closeStaticTab() {
  495. this.$alert('确定要删除该标签?删除后该标签内容将会被清空!', '提示', {
  496. confirmButtonText: '确定',
  497. cancelButtonText: '取消',
  498. // cancelButtonClass: 'leaveBtn',
  499. // customClass: 'leaveBox',
  500. type: 'warning'
  501. })
  502. .then(() => {
  503. this.staticTabShow = false;
  504. this.tabActiveChange('two');
  505. })
  506. .catch(() => {});
  507. },
  508. closeAssesTab() {
  509. this.$alert('确定要删除该标签?删除后该标签内容将会被清空!', '提示', {
  510. confirmButtonText: '确定',
  511. cancelButtonText: '取消',
  512. // cancelButtonClass: 'leaveBtn',
  513. // customClass: 'leaveBox',
  514. type: 'warning'
  515. })
  516. .then(() => {
  517. this.AssesTabSHow = false;
  518. // this.AssesComSHow = false;
  519. this.tabActiveChange('one');
  520. })
  521. .catch(() => {});
  522. },
  523. tabActiveChange(type) {
  524. this.tabActive = type;
  525. if (type == 'two') {
  526. setTimeout(() => {
  527. this.$refs.assessRef.resizeTable();
  528. }, 200);
  529. }
  530. },
  531. handleClear() {
  532. this.form.selectedTermName = '';
  533. this.form.selectedTerm = '';
  534. this.form.titleChange = '';
  535. },
  536. handleMouseenter() {
  537. if (this.form.fileList.length !== 0) {
  538. this.isShowTip = true;
  539. }
  540. },
  541. handleMouseleave() {
  542. this.isShowTip = false;
  543. },
  544. changeWord(newVal) {
  545. if (newVal.typeName == '量表') {
  546. this.AssesComSHow = true;
  547. } else {
  548. this.staticTabShow = true;
  549. this.AssesComSHow = false;
  550. this.tabActive = 'one';
  551. }
  552. this.toAssesTermId = newVal.id;
  553. this.showType = newVal.type || -1;
  554. const name = newVal.name;
  555. const typeName = newVal.typeName;
  556. const type = newVal.type;
  557. this.form.selectedTermName =
  558. name + (typeName ? '(' + typeName + ')' : '');
  559. // this.form.selectedTerm = name + (typeName ? '(' + typeName + ')' : '');
  560. this.form.name = name;
  561. this.form.fileList = [];
  562. this.showFileList = false;
  563. this.form.typeId = type || '';
  564. this.showUpLoad = true;
  565. this.titleChange =
  566. type == 1
  567. ? '临床路径标题:'
  568. : type == 3 || type == 4 || type == 5 || type == 6
  569. ? '注意事项标题:'
  570. : '';
  571. this.form.fileTitle = '';
  572. if (newVal.typeId === 82 || newVal.typeId === 83) {
  573. this.upload = true;
  574. this.form.fileTitle = newVal.title;
  575. } else {
  576. this.upload = false;
  577. }
  578. },
  579. handleVisible(flag) {
  580. if (!flag) {
  581. this.terms = [];
  582. }
  583. },
  584. reOrder(isUp, i) {
  585. // isUp: 1 上升 0 下降
  586. let div = this.$refs['elscrollbar'].$refs['wrap'];
  587. let temp = {},
  588. it = {};
  589. if (isUp === 1) {
  590. if (i === 0) {
  591. this.warning('已经是第一个,不能再升啦!');
  592. return;
  593. }
  594. temp = Object.assign(this.form.prags[i - 1]);
  595. it = Object.assign(this.form.prags[i]);
  596. this.form.prags.splice(i - 1, 2, it, temp);
  597. this.$nextTick(() => {
  598. div.scrollTop = this.$refs.subForm[i - 1].$el.offsetTop - 48;
  599. });
  600. } else {
  601. if (i === this.form.prags.length - 1) {
  602. this.warning('已经是最后一个,不能再降啦!');
  603. return;
  604. }
  605. temp = Object.assign(this.form.prags[i + 1]);
  606. it = Object.assign(this.form.prags[i]);
  607. this.form.prags.splice(i, 2, temp, it);
  608. }
  609. },
  610. addParagraph(i) {
  611. this.form.prags.splice(i + 1, 0, {
  612. title: '',
  613. content: '',
  614. isReason: 0,
  615. position: [],
  616. text: ''
  617. });
  618. //添加段落光标自动落到新增的段落中
  619. setTimeout(() => {
  620. this.$refs.subForm[i + 1].$el
  621. .getElementsByClassName('el-input__inner')[0]
  622. .focus();
  623. });
  624. },
  625. delParagraph(i) {
  626. if (this.form.prags.length == 1) {
  627. this.warning('只剩一个段落,不能再删啦!');
  628. return;
  629. }
  630. this.showConfirmDialog('确定要删除该段落?', () => {
  631. this.form.prags.splice(i, 1);
  632. });
  633. },
  634. back() {
  635. this.$router.go(-1);
  636. },
  637. searchTerms(query) {
  638. if (!query.trim()) {
  639. this.form.terms = [];
  640. return;
  641. }
  642. //搜索术语列表
  643. this.showDrop = true;
  644. api
  645. .staticKnowledgeBaseInfo({ inputStr: query.trim(), types: [0] })
  646. .then(res => {
  647. this.showDrop = false;
  648. if (res.data.code === '0') {
  649. this.terms = res.data.data;
  650. } else {
  651. this.warning('数据获取失败');
  652. }
  653. });
  654. },
  655. mapStringToNum(str) {
  656. return str.split(',').map(it => {
  657. return +it;
  658. });
  659. },
  660. // 额外的表单检验
  661. formVal() {
  662. let positiontemp = this.form.prags.map(item => {
  663. return [...item.position];
  664. });
  665. let positionArr = positiontemp.reduce(function(a, b) {
  666. return a.concat(b);
  667. }); // 所有被选中的值集合
  668. // console.log(positionArr, 'positionArr');
  669. // console.log(this.showType, '当前页的显示类型');
  670. let isVisFlag = positionArr.some(item => item === '2');
  671. let isDiagFlag = positionArr.some(item => item === '3');
  672. // console.log(isVisFlag, 'isVisFlag是否显示');
  673. if (
  674. (this.showType == 3 ||
  675. this.showType == 4 ||
  676. this.showType == 5 ||
  677. this.showType == 6) &&
  678. isVisFlag
  679. ) {
  680. // console.log("进入校验");
  681. //若医学术语为检验/检查,且内容类型选择了注意事项,此时“注意事项标题”是必填项
  682. this.$refs.groups && this.$refs.groups.clearValidate();
  683. this.rules.titleChange.push({
  684. required: true,
  685. message: '请输入注意事项标题',
  686. trigger: 'change'
  687. });
  688. this.$refs.groups && this.$refs.groups.validateField('titleChange');
  689. this.$refs.groups && this.$refs.groups.validateField('selectedTerm');
  690. this.rules.titleChange = this.rules.titleChange.slice(0, 1);
  691. if (this.form.titleChange.trim() !== '') {
  692. // console.log('内容不为空');
  693. return true;
  694. } else {
  695. var div = this.$refs['elscrollbar'].$refs['wrap'];
  696. this.$nextTick(() => {
  697. div.scrollTop = 0;
  698. });
  699. return false;
  700. }
  701. // return;
  702. } else if (isDiagFlag && this.showType == 1) {
  703. // 若医学术语为诊断,且内容类型选择了临床路径,此时“临床路径标题”是必填项
  704. this.$refs.groups && this.$refs.groups.clearValidate();
  705. this.rules.titleChange.push({
  706. required: true,
  707. message: '请输入临床路径标题',
  708. trigger: 'change'
  709. });
  710. this.$refs.groups && this.$refs.groups.validateField('titleChange');
  711. this.$refs.groups && this.$refs.groups.validateField('selectedTerm');
  712. this.rules.titleChange = this.rules.titleChange.slice(0, 1);
  713. if (this.form.titleChange.trim() !== '') {
  714. // console.log('内容不为空');
  715. return true;
  716. } else {
  717. var div = this.$refs['elscrollbar'].$refs['wrap'];
  718. this.$nextTick(() => {
  719. div.scrollTop = 0;
  720. });
  721. return false;
  722. }
  723. }
  724. },
  725. async submitForm() {
  726. let all = [];
  727. let goOn = true,
  728. it = null;
  729. let assessRule = false;
  730. let viewHeight = 0; // 定位到表单校验的高度
  731. let viewHeightArr = []; // 表单校验出错高度的所有数组
  732. let outIsVia = true; // 外层验证是否通过
  733. let fvalidate1 = new Promise((resolve, reject) => {
  734. //wanglei 添加promise
  735. this.$refs.groups1.validate((valid, object) => {
  736. if (valid) {
  737. resolve(true);
  738. } else {
  739. reject('top', object);
  740. return false;
  741. }
  742. });
  743. });
  744. all.push(fvalidate1);
  745. if (this.staticTabShow) {
  746. if (this.isSuccessUpload === 1) {
  747. this.warning('文件上传中,请稍等');
  748. return;
  749. }
  750. let flagVal = this.formVal(); // 额外的表单校验
  751. if (flagVal === false) return;
  752. //验证外层表单
  753. let fvalidate = new Promise((resolve, reject) => {
  754. //wanglei 添加promise
  755. this.$refs.groups &&
  756. this.$refs.groups.validate((valid, object) => {
  757. if (valid) {
  758. resolve(true);
  759. } else {
  760. reject('f', object);
  761. return false;
  762. }
  763. });
  764. });
  765. // end....
  766. //验证段落表单
  767. // return;
  768. all.push(fvalidate);
  769. if (this.form.typeId !== 82 && this.form.typeId !== 83) {
  770. for (let i = 0; i < this.$refs.subForm.length; i++) {
  771. all.push(
  772. new Promise((resolve, reject) => {
  773. it = this.$refs.subForm[i];
  774. // viewHeight += it.$el.getBoundingClientRect().top;
  775. it.$refs.form.validate((valid, object) => {
  776. if (!valid) {
  777. reject('f', object);
  778. goOn = false;
  779. viewHeightArr.push(it.$el);
  780. } else {
  781. resolve(true);
  782. }
  783. });
  784. })
  785. );
  786. }
  787. }
  788. }
  789. // 表单验证
  790. if (this.$refs.assessRef) {
  791. all.push(...this.$refs.assessRef.assessCommit());
  792. }
  793. // 批量处理Promise返回
  794. let transferedPromises = promises => {
  795. // 返回一个处理之后的promise数组
  796. return promises.map(promise => {
  797. return promise.then(res => res).catch(err => err);
  798. });
  799. };
  800. let promiseArr = transferedPromises(all);
  801. await Promise.all(promiseArr).then(resArr => {
  802. let cErrIndex = resArr.findIndex(item => item.type == 'c');
  803. let fErrIndex = resArr.findIndex(item => item == 'f');
  804. let topErrIndex = resArr.findIndex(item => item == 'top');
  805. if (topErrIndex != -1) {
  806. outIsVia = false;
  807. var div = this.$refs['elscrollbar'].$refs['wrap'];
  808. this.$nextTick(() => {
  809. div.scrollTop = 0;
  810. });
  811. } else if (cErrIndex != -1 && fErrIndex != -1) {
  812. if (this.staticTabShow) {
  813. goOn = false;
  814. }
  815. this.tabActive = 'one';
  816. this.$message({
  817. showClose: true,
  818. message: `"静态信息"和"评估内容"标签内有未填写项目,请填写完整或者删除该标签!`,
  819. type: 'warning'
  820. });
  821. } else if (cErrIndex != -1 && fErrIndex == -1) {
  822. this.tabActive = 'two';
  823. this.$message({
  824. showClose: true,
  825. message: `"评估内容"标签内有未填写项目,请填写完整或者删除该标签!`,
  826. type: 'warning'
  827. });
  828. let cErrArr = resArr.filter(item => item.type == 'c');
  829. if (cErrArr) {
  830. cErrArr = Object.keys(cErrArr[0].object);
  831. }
  832. this.$nextTick(() => {
  833. setTimeout(() => {
  834. let domTop = this.$refs.assessRef.getDom(cErrArr[0]);
  835. var div = this.$refs['elscrollbar'].$refs['wrap'];
  836. if (domTop >= 0) {
  837. div.scrollTop += domTop - 120;
  838. } else {
  839. div.scrollTop -= Math.abs(domTop) + 120;
  840. }
  841. }, 100);
  842. });
  843. } else if (cErrIndex == -1 && fErrIndex != -1&&this.form.typeId=='8') {
  844. this.tabActive = 'one';
  845. this.$message({
  846. showClose: true,
  847. message: `"静态信息"标签内有未填写项目,请填写完整或者删除该标签!`,
  848. type: 'warning'
  849. });
  850. } else {
  851. assessRule = true;
  852. }
  853. });
  854. if (this.staticTabShow && !goOn) {
  855. setTimeout(() => {
  856. var div = this.$refs['elscrollbar'].$refs['wrap'];
  857. if (outIsVia) {
  858. // 外层校验通过,跳转至下层校验具体位置
  859. let sTop = viewHeightArr[0].getBoundingClientRect().top;
  860. this.$nextTick(() => {
  861. if (sTop >= 0) {
  862. div.scrollTop += sTop - 120;
  863. } else {
  864. div.scrollTop -= Math.abs(sTop) + 120;
  865. }
  866. });
  867. } else {
  868. // 外层校验没通过,页面滚动到顶部
  869. this.$nextTick(() => {
  870. div.scrollTop = 0;
  871. });
  872. }
  873. }, 200);
  874. return;
  875. }
  876. if (!assessRule) return;
  877. //通过必填验证,提交保存
  878. let param = [];
  879. // const item = this.form.prags;
  880. if (this.form.typeId === 82 || this.form.typeId === 83) {
  881. if (this.form.fileList.length === 0) {
  882. this.warning('文件未上传,不存储数据');
  883. return;
  884. }
  885. param.push(
  886. Object.assign(
  887. {},
  888. {
  889. position: this.form.typeId === 82 ? '8' : '9',
  890. conceptId: this.form.conceptId,
  891. title: this.form.fileTitle,
  892. orderNo: 0,
  893. content: JSON.stringify(this.form.fileList[0])
  894. }
  895. )
  896. );
  897. } else {
  898. // if (this.staticTabShow) {
  899. // }
  900. let data = this.form.prags,
  901. tempArr = [],
  902. paramsAll = {},
  903. types = this.form.typeId;
  904. for (let i = 0; i < data.length; i++) {
  905. let obj = {};
  906. obj.content = data[i].content;
  907. obj.text = data[i].text;
  908. obj.conceptId = data[i].conceptId;
  909. obj.orderNo = i;
  910. obj.title = data[i].title;
  911. obj.contentType = data[i].position.join(',');
  912. tempArr.push(obj);
  913. }
  914. paramsAll.clinicalPathwayName = types == 1 ? this.form.titleChange : '';
  915. paramsAll.id = this.conceptId;
  916. paramsAll.name = this.form.name;
  917. paramsAll.noticeName =
  918. types == 3 || types == 4 || types == 5 || types == 6
  919. ? this.form.titleChange
  920. : '';
  921. paramsAll.type = this.form.typeId;
  922. if (this.staticTabShow) {
  923. paramsAll.details = tempArr;
  924. } else {
  925. paramsAll.details = null;
  926. }
  927. param = paramsAll;
  928. if (!param.details) param.details = [];
  929. param.details.forEach(item => {
  930. let regExp = new RegExp(config.imgHost, 'g');
  931. item.content = item.content.replace(regExp, '{imageUrlPrefix}');
  932. });
  933. // 评估内容的数据
  934. param.scale = {};
  935. console.log(
  936. 'this.AssesComSHow',
  937. this.AssesComSHow,
  938. 'AssesTabSHow',
  939. this.AssesTabSHow
  940. );
  941. if (this.AssesComSHow && this.AssesTabSHow) {
  942. const assessParam = this.$refs.assessRef.formtParams();
  943. param.scale = assessParam;
  944. param.scale.conceptId = this.toAssesTermId;
  945. const userInfo = localStorage.getItem('userLoginDTO');
  946. param.scale.modifier = userInfo.linkman;
  947. }
  948. }
  949. // return;
  950. // this.showSaveDialog(param,'是否'+(this.isEdit?'修改':'保存')+'该静态知识?');
  951. console.log('param-------');
  952. console.dir(param);
  953. // return;
  954. if (!this.isEdit) {
  955. // 新增页面
  956. this.saveDisable = true;
  957. this.sendSaveOrEdit(param);
  958. return;
  959. }
  960. this.showSaveDialog(
  961. param,
  962. '<div><p style="color: #333333">确定保存修改内容?</p><p style="color: #D70A25">保存后将覆盖原有数据,且原有数据无法恢复。</p></div>'
  963. );
  964. },
  965. showSaveDialog(param, msg) {
  966. this.showConfirmDialog(msg, () => {
  967. this.saveDisable = true; //提交保存按钮不可点击,返回结果时才可点击,防止频繁发送请求
  968. this.sendSaveOrEdit(param);
  969. });
  970. },
  971. //保存编辑 接口
  972. sendSaveOrEdit(param) {
  973. this.isCopy && (param.id = undefined);
  974. param.source = 1; //0:医院端 1:云平台
  975. api
  976. .saveBaseOrUpdateRecord(param)
  977. .then(res => {
  978. if (res.data.code === '0') {
  979. this.isSuccessUpload = 0; // 修改文件上传状态为0
  980. this.warning(res.data.msg || '保存成功', 'success');
  981. this.isSaveSuccess = true; // 保存成功,可正常退出
  982. //返回带搜索条件的首页
  983. this.$router.push({
  984. name: 'StaticInfo',
  985. params: Object.assign({}, this.$route.params, {
  986. currentPage: 1
  987. })
  988. });
  989. } else {
  990. this.warning(res.data.msg);
  991. }
  992. this.saveDisable = false;
  993. })
  994. .catch(err => {
  995. if (err.code === '900010001') {
  996. return false;
  997. }
  998. this.saveDisable = false;
  999. this.warning(err);
  1000. });
  1001. },
  1002. // 弹出窗
  1003. showConfirmDialog(msg, resolve) {
  1004. this.$alert(msg, '提示', {
  1005. confirmButtonText: '确定',
  1006. // cancelButtonText: '取消',
  1007. // cancelButtonClass: 'cancel',
  1008. // confirmButtonClass: 'confirmBtn',
  1009. dangerouslyUseHTMLString: true,
  1010. type: 'warning'
  1011. })
  1012. .then(() => {
  1013. resolve();
  1014. })
  1015. .catch(() => {});
  1016. },
  1017. warning(msg, type) {
  1018. this.$message({
  1019. showClose: true,
  1020. message: msg,
  1021. type: type || 'warning',
  1022. duration:1000
  1023. });
  1024. },
  1025. handleChange(file, fileList) {
  1026. // if(fileList&&fileList[0]&&fileList[0].response&&fileList[0].response.code==='0'){
  1027. // this.showUpLoad = false
  1028. // this.showFileList = true
  1029. // }else{
  1030. // this.showUpLoad = true
  1031. // this.showFileList = false
  1032. // }
  1033. // console.log(fileList,this.form.fileList,'aa')
  1034. },
  1035. handleSuccess(response, file, fileList) {
  1036. if (response.code == '0') {
  1037. this.showFileList = true;
  1038. this.form.fileList = [];
  1039. this.form.fileList.push({
  1040. name: response.data.title,
  1041. url: response.data.url,
  1042. size: response.data.size
  1043. });
  1044. this.showUpLoad = false;
  1045. if (!this.form.fileTitle) {
  1046. this.form.fileTitle = response.data.title;
  1047. }
  1048. this.isSuccessUpload = 2; // 上传成功状态
  1049. this.$refs.upload && this.$refs.upload.clearValidate(); // 清除校验
  1050. } else {
  1051. this.warning(response.msg || '上传失败');
  1052. // this.form.fileList = []
  1053. this.showUpLoad = true;
  1054. this.showFileList = false;
  1055. this.form.fileList = [];
  1056. }
  1057. },
  1058. handleRemove(file, fileList) {
  1059. this.showUpLoad = true;
  1060. this.form.fileList = [];
  1061. this.isSuccessUpload = 0;
  1062. },
  1063. handleBeforeUpLoad(file) {
  1064. // 上传过程中 上传按钮 隐藏
  1065. this.isSuccessUpload = 1; // 上传过程中
  1066. this.showFileList = true; // 新增 进度条 显示
  1067. this.$refs.upload && this.$refs.upload.clearValidate(); // 清除校验
  1068. this.showUpLoad = false;
  1069. if (file.size / 1024 / 1024 >= 500) {
  1070. this.warning('文件上传失败,超出大小限制500MB');
  1071. this.form.fileList = [];
  1072. this.showConfirm = false;
  1073. return false;
  1074. } else {
  1075. this.showConfirm = true;
  1076. }
  1077. },
  1078. handlePreview(file) {},
  1079. beforeRemove(file, fileList) {
  1080. if (this.showConfirm) {
  1081. return this.$alert(`确定移除 ${file.name}?`, '', {
  1082. cancelButtonClass: 'cacelBtn'
  1083. });
  1084. }
  1085. }
  1086. }
  1087. };
  1088. </script>
  1089. <style lang="less" scoped>
  1090. @import '../../less/common.less';
  1091. .cell .el-button.delete:focus {
  1092. color: red !important;
  1093. }
  1094. .topBack {
  1095. top: 0;
  1096. }
  1097. .info-container {
  1098. // background: #fff;
  1099. // padding: 20px 0;
  1100. margin: 60px 20px -20px 20px;
  1101. min-width: 960px;
  1102. .el-input__inner {
  1103. width: 200px;
  1104. }
  1105. .el-form-item__label {
  1106. text-align: left;
  1107. }
  1108. .add-prg .el-form-item {
  1109. margin-bottom: 20px;
  1110. }
  1111. // .el-form-item {
  1112. // margin-bottom: 8px !important;
  1113. // }
  1114. }
  1115. // .cancel span {
  1116. // color: #22ccc8;
  1117. // }
  1118. .line {
  1119. // border-top: 1px #dcdfe6 solid;
  1120. background: #dcdfe6;
  1121. height: 12px;
  1122. }
  1123. .NoiseTemplateWrapper .info-container .el-input__inner {
  1124. width: 250px;
  1125. }
  1126. // .NoiseTemplateWrapper .el-select .el-input .el-icon-circle-close{
  1127. // display: inherit!important;
  1128. // }
  1129. .cacelBtn {
  1130. color: #22ccc8 !important;
  1131. }
  1132. .upload-demo {
  1133. width: 300px;
  1134. /deep/.el-upload-list__item .el-icon-close-tip {
  1135. display: none !important;
  1136. }
  1137. /deep/.el-upload-list__item .el-upload-list__item-name {
  1138. max-width: 250px;
  1139. white-space: nowrap;
  1140. overflow: hidden;
  1141. text-overflow: ellipsis;
  1142. }
  1143. /deep/ .focusing {
  1144. // border: 1px solid transparent !important;
  1145. outline: transparent !important;
  1146. }
  1147. }
  1148. .uploadInfo {
  1149. margin-top: -20px;
  1150. color: #606266;
  1151. }
  1152. .tipInfo {
  1153. position: absolute;
  1154. // position: relative;
  1155. line-height: 24px;
  1156. top: -56px;
  1157. left: 20px;
  1158. // background-color: transparent;
  1159. // color: #606266;
  1160. padding: 3px 10px;
  1161. border-radius: 4px;
  1162. margin: 100px auto;
  1163. background-color: #4d4d4d;
  1164. text-align: center;
  1165. color: #fff;
  1166. font-size: 14px;
  1167. }
  1168. .tipInfo:before {
  1169. content: '';
  1170. display: block;
  1171. position: absolute;
  1172. // bottom: 9px;
  1173. top: -10px;
  1174. left: 18px;
  1175. border-bottom: 6px solid #4d4d4d;
  1176. border-top: 6px solid transparent;
  1177. border-left: 6px solid transparent;
  1178. border-right: 6px solid transparent;
  1179. // border-right: 6px solid #4D4D4D;
  1180. }
  1181. .btn {
  1182. text-align: right;
  1183. margin: 10px 20px;
  1184. padding: 30px;
  1185. background: #fff;
  1186. }
  1187. .el-message-box {
  1188. /deep/ .el-icon-warning {
  1189. background-color: transparent !important;
  1190. // display: none;
  1191. }
  1192. /deep/ .el-message-box__message {
  1193. margin: 24px 0px;
  1194. }
  1195. // /deep/ .confirmBtn {
  1196. // // position: relative;
  1197. // // right: 240px !important;
  1198. // // top: 0px;
  1199. // background-color: #fff !important;
  1200. // span {
  1201. // color: #48c5d7 !important;
  1202. // }
  1203. // }
  1204. /deep/ .cancel {
  1205. background-color: #d7d7d7;
  1206. border-color: transparent !important;
  1207. span {
  1208. color: #fff;
  1209. }
  1210. }
  1211. }
  1212. /deep/ .el-tabs__header {
  1213. padding: 0 10px !important;
  1214. }
  1215. .container_top {
  1216. display: flex;
  1217. padding: 20px 30px;
  1218. }
  1219. .tabs_box {
  1220. display: flex;
  1221. align-items: center;
  1222. }
  1223. .tabs {
  1224. display: flex;
  1225. margin: 0px 30px;
  1226. font-size: 14px;
  1227. height: 31px;
  1228. .tabs_pane {
  1229. position: relative;
  1230. width: 92px;
  1231. height: 32px;
  1232. border-radius: 6px 6px 0px 0px;
  1233. border: 1px solid #00c7da;
  1234. text-align: center;
  1235. line-height: 32px;
  1236. margin-right: 32px;
  1237. box-sizing: border-box;
  1238. color: #00c7da;
  1239. cursor: pointer;
  1240. img {
  1241. position: absolute;
  1242. right: -18px;
  1243. bottom: 0;
  1244. width: 18px;
  1245. height: 18px;
  1246. }
  1247. }
  1248. }
  1249. .tab_box_left {
  1250. padding: 30px;
  1251. }
  1252. /deep/ .el-form-item.is-success .el-input__inner,
  1253. .el-form-item.is-success .el-textarea__inner {
  1254. border-color: #c9c9c9 !important;
  1255. }
  1256. /deep/ .el-form-item.is-success .el-textarea__inner {
  1257. border-color: #c9c9c9 !important;
  1258. }
  1259. /deep/ .el-form-item.is-success .el-textarea__inner {
  1260. border-color: #c9c9c9 !important;
  1261. }
  1262. </style>