AddMedicinePrompt.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868
  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="MedicinePrompt"
  9. ></crumbs>
  10. <div class="info-container">
  11. <el-form :rules="rules" :model="form" label-width="160px" ref="groups">
  12. <el-form-item v-if="!isEdit" label="选择标准术语:" prop="selectedTerm">
  13. <el-select
  14. v-model="form.selectedTerm"
  15. filterable
  16. remote
  17. clearable
  18. :loading="showDrop"
  19. loading-text="加载中..."
  20. @change="changeWord"
  21. @visible-change="handleVisible"
  22. value-key="id"
  23. @clear="handleClear"
  24. ref="termName"
  25. placeholder="搜索"
  26. :remote-method="searchTerms"
  27. >
  28. <el-option
  29. v-for="(term,idx) in terms"
  30. :key="idx"
  31. :label="term.name+(term.typeName?'('+term.typeName+')':'')"
  32. :value="term"
  33. :title="term.name+(term.typeName?'('+term.typeName+')':'')"
  34. ></el-option>
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item label="已选择标准术语:" label-width="160px">{{form.selectedTermName}}</el-form-item>
  38. <el-form-item
  39. v-if="form.selectedTerm&&(form.typeId==1||form.typeId==3||form.typeId==4||form.typeId==5||form.typeId==6)"
  40. :label="titleChange"
  41. prop="titleChange"
  42. label-width="160px"
  43. >
  44. <el-input v-model="form.titleChange"></el-input>
  45. </el-form-item>
  46. <p class="line"></p>
  47. <InfoParagraph
  48. v-for="(f,i) in form.prags"
  49. v-if="!upload"
  50. :key="(i+1)*10000 + showType"
  51. :data="f"
  52. :index="i"
  53. :total="form.prags.length"
  54. :isEdit="isEdit"
  55. ref="subForm"
  56. @add="addParagraph(i)"
  57. @del="delParagraph"
  58. @reOrder="reOrder"
  59. :showType="showType"
  60. ></InfoParagraph>
  61. <el-form-item v-if="upload" label="标题名称:" prop="fileTitle" label-width="160px">
  62. <el-input v-model="form.fileTitle"></el-input>
  63. </el-form-item>
  64. <el-form-item
  65. v-if="upload"
  66. label="上传文件:"
  67. ref="upload"
  68. prop="fileList"
  69. label-width="160px"
  70. >
  71. <el-upload
  72. @mouseenter.native="handleMouseenter"
  73. @mouseleave.native="handleMouseleave"
  74. class="upload-demo"
  75. :action="config.urls.promptServer"
  76. name="upfile"
  77. :multiple="false"
  78. :limit="1"
  79. :on-preview="handlePreview"
  80. :on-remove="handleRemove"
  81. :before-upload="handleBeforeUpLoad"
  82. :before-remove="beforeRemove"
  83. :on-change="handleChange"
  84. :on-success="handleSuccess"
  85. :show-file-list="showFileList"
  86. :file-list="form.fileList"
  87. >
  88. <el-button size="small" type="primary" v-if="showUpLoad">点击上传</el-button>
  89. <!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div> -->
  90. </el-upload>
  91. <span class="tipInfo" v-show="isShowTip">{{form.fileList[0]&&form.fileList[0].name}}</span>
  92. <!-- <el-button size="small" type="primary" >点击上传</el-button> -->
  93. </el-form-item>
  94. <el-form-item label-width="160px">
  95. <div class="uploadInfo" v-if="isSuccessUpload===1">文件上传中,请稍等...</div>
  96. </el-form-item>
  97. </el-form>
  98. <div class="btn">
  99. <el-button type="primary" :disabled="saveDisable" @click="submitForm">确 定</el-button>
  100. </div>
  101. </div>
  102. </div>
  103. </el-scrollbar>
  104. </template>
  105. <script>
  106. /**
  107. *
  108. */
  109. import api from '@api/icss.js';
  110. import InfoParagraph from './MedicineInfoPg';
  111. import config from '@api/config';
  112. export default {
  113. name: 'AddMedicinePrompt',
  114. components: {
  115. InfoParagraph
  116. },
  117. data() {
  118. return {
  119. isFixedTop: true,
  120. isEdit: false,
  121. isCopy: false,
  122. title: '添加',
  123. termTypes: [],
  124. terms: [], //术语列表
  125. form: {
  126. conceptId: '', //术语id
  127. isTip: 0, //是否要覆盖,0不覆盖,1覆盖
  128. selectedTerm: '', //术语标签
  129. termType: '',
  130. typeId: '',
  131. selectedTermName: '',
  132. selectedTermType: '',
  133. // titleChange: '',
  134. fileList: [],
  135. name: '',
  136. prags: [
  137. {
  138. //单个段落相关
  139. title: '',
  140. content: '',
  141. isReason: 0,
  142. orderNo: 0,
  143. position: [],
  144. text: ''
  145. }
  146. ],
  147. fileTitle: '',
  148. titleChange: ''
  149. },
  150. rules: {
  151. selectedTerm: [
  152. { required: true, message: '请选择术语标签', trigger: 'change' }
  153. ],
  154. fileTitle: [
  155. { required: true, message: '请输入标题名称', trigger: 'change' },
  156. {
  157. validator: (rule, value, callback) => {
  158. if (value.length > 30) {
  159. callback(new Error('标题名称不能超过30字'));
  160. } else {
  161. callback();
  162. }
  163. },
  164. trigger: 'change'
  165. }
  166. ],
  167. fileList: [
  168. { required: true, message: '请上传文件', trigger: 'change' }
  169. ],
  170. titleChange: [{ max: 30, message: '标题最多30字', trigger: 'change' }]
  171. },
  172. saveDisable: false, //保存按钮禁止点击
  173. showDrop: false, //下拉框显示文字bug1774
  174. config: config,
  175. showUpLoad: true,
  176. showFileList: false,
  177. upload: false,
  178. showConfirm: true,
  179. isSuccessUpload: 0, //是否上传成功 0: 不在上传 1: 上传过程中 2: 上传成功
  180. isShowTip: false,
  181. showType: -1, // 1 诊断 2 药品 3检验套餐 4检验细项 5检查 6检查子 7手术和操作 8量表 9护理
  182. editCount: -1, // 页面会否被编辑 >0被编辑 =0 未编辑
  183. startCount: -1,
  184. isSaveSuccess: false // 是否保存成功
  185. };
  186. },
  187. watch: {
  188. showType: {
  189. handler(newVal, oldVal) {
  190. // console.log('newVal============', newVal, 'oldVal============', oldVal);
  191. if (newVal !== oldVal) {
  192. this.form.prags = this.form.prags.map(item => {
  193. return { ...item, position: [] };
  194. });
  195. }
  196. }
  197. },
  198. form: {
  199. handler(newName, oldName) {
  200. this.editCount++;
  201. },
  202. deep: true,
  203. immediate: true
  204. }
  205. },
  206. created: function() {
  207. const { isEdit, data, isCopy } = this.$route.params;
  208. console.log('静态数据???',data)
  209. if (isEdit || isCopy) {
  210. this.showType = data.type; // 编辑页确认显示类型
  211. this.isEdit = isEdit;
  212. this.isCopy = isCopy;
  213. this.title = isEdit ? '修改' : isCopy ? '复制' : '添加';
  214. isEdit && this.changeWord(data);
  215. api
  216. .getTremList({ id: data.id })
  217. .then(res => {
  218. if (res.data.code == '0') {
  219. const data = res.data.data;
  220. if (this.form.typeId === 82 || this.form.typeId === 83) {
  221. // console.log('data',data)
  222. this.form.fileList =
  223. data &&
  224. data.map(it => {
  225. return JSON.parse(it.content);
  226. });
  227. this.showFileList = true;
  228. this.showUpLoad = false;
  229. } else {
  230. this.conceptId = data.id;
  231. this.form.typeId = data.type;
  232. this.form.name = data.name;
  233. this.form.titleChange =
  234. data.type == 1
  235. ? data.clinicalPathwayName
  236. : data.type == 3 || data.type == 4 || data.type == 5|| data.type == 6
  237. ? data.noticeName
  238. : '';
  239. this.form.selectedTermName =
  240. data.name + (data.typeName ? '(' + data.typeName + ')' : '');
  241. this.form.selectedTerm =
  242. data.name + (data.typeName ? '(' + data.typeName + ')' : '');
  243. if(data &&data.details&&data.details.length===0){ //量表有评估内容没有静态知识的情况
  244. this.form.prags =[
  245. {
  246. title: '',
  247. content: '',
  248. isReason: 0,
  249. orderNo: 0,
  250. position: [],
  251. text: ''
  252. }
  253. ];
  254. return;
  255. }
  256. this.form.prags =
  257. data &&
  258. data.details.map(it => {
  259. return {
  260. title: it.title,
  261. position: (it.contentType||'').split(","),
  262. content: it.content && it.content.replace(
  263. /{imageUrlPrefix}/g,
  264. config.imgHost
  265. ),
  266. // isReason:it.isReason,
  267. text: it.text,
  268. disabled: true
  269. };
  270. });
  271. }
  272. }
  273. })
  274. .catch(error => {
  275. if (error.code === '900010001') {
  276. return false;
  277. }
  278. console.log(error);
  279. });
  280. }
  281. setTimeout(() => {
  282. this.startCount = this.editCount;
  283. }, 500);
  284. },
  285. mounted() {},
  286. beforeRouteLeave(to, from, next) {
  287. // if (this.isSuccessUpload === 1) {
  288. // this.$confirm('文件正在上传,是否确定返回?', '提示', {
  289. // confirmButtonText: '确定',
  290. // cancelButtonText: '取消',
  291. // cancelButtonClass: 'cancel',
  292. // type: 'warning'
  293. // })
  294. // .then(() => {
  295. // next();
  296. // })
  297. // .catch(() => {});
  298. // // this.warning('还有未保存的文件,是否确定返回?');
  299. // } else if (this.isSuccessUpload === 2) {
  300. // this.$confirm('还有未保存的文件,是否确定返回?', '提示', {
  301. // confirmButtonText: '确定',
  302. // cancelButtonText: '取消',
  303. // cancelButtonClass: 'cancel',
  304. // type: 'warning'
  305. // })
  306. // .then(() => {
  307. // next();
  308. // })
  309. // .catch(() => {});
  310. // } else {
  311. // next();
  312. // }
  313. if (this.startCount !== this.editCount && !this.isSaveSuccess) {
  314. this.$confirm('还有未保存的内容,确定要退出当前页面吗?', '提示', {
  315. confirmButtonText: '确定',
  316. cancelButtonText: '取消',
  317. cancelButtonClass: 'leaveBtn',
  318. customClass: 'leaveBox',
  319. type: 'warning'
  320. })
  321. .then(() => {
  322. next();
  323. })
  324. .catch(() => {});
  325. } else {
  326. next();
  327. }
  328. },
  329. methods: {
  330. handleClear() {
  331. this.form.selectedTermName = '';
  332. this.form.selectedTerm = '';
  333. this.form.titleChange = '';
  334. // console.log('处理清空的操作');
  335. },
  336. handleMouseenter() {
  337. if (this.form.fileList.length !== 0) {
  338. this.isShowTip = true;
  339. }
  340. },
  341. handleMouseleave() {
  342. this.isShowTip = false;
  343. },
  344. changeWord(newVal) {
  345. this.showType = newVal.type || -1;
  346. const name = newVal.name;
  347. const typeName = newVal.typeName;
  348. const type = newVal.type;
  349. this.form.selectedTermName = name + (typeName ? '(' + typeName + ')' : '');
  350. // this.form.selectedTerm = name + (typeName ? '(' + typeName + ')' : '');
  351. this.form.name = name;
  352. this.form.fileList = [];
  353. this.showFileList = false;
  354. this.form.typeId = type || '';
  355. this.showUpLoad = true;
  356. this.titleChange =
  357. type == 1
  358. ? '临床路径标题:'
  359. : type == 3 || type == 4 || type == 5 || type == 6
  360. ? '注意事项标题:'
  361. : '';
  362. this.form.fileTitle = '';
  363. if (newVal.typeId === 82 || newVal.typeId === 83) {
  364. this.upload = true;
  365. this.form.fileTitle = newVal.title;
  366. } else {
  367. this.upload = false;
  368. }
  369. },
  370. handleVisible(flag) {
  371. if (!flag) {
  372. this.terms = [];
  373. }
  374. },
  375. reOrder(isUp, i) {
  376. // isUp: 1 上升 0 下降
  377. let div = this.$refs['elscrollbar'].$refs['wrap'];
  378. let temp = {},
  379. it = {};
  380. if (isUp === 1) {
  381. if (i === 0) {
  382. this.warning('已经是第一个,不能再升啦!');
  383. return;
  384. }
  385. temp = Object.assign(this.form.prags[i - 1]);
  386. it = Object.assign(this.form.prags[i]);
  387. this.form.prags.splice(i - 1, 2, it, temp);
  388. this.$nextTick(() => {
  389. div.scrollTop = this.$refs.subForm[i - 1].$el.offsetTop - 48;
  390. });
  391. } else {
  392. if (i === this.form.prags.length - 1) {
  393. this.warning('已经是最后一个,不能再降啦!');
  394. return;
  395. }
  396. temp = Object.assign(this.form.prags[i + 1]);
  397. it = Object.assign(this.form.prags[i]);
  398. this.form.prags.splice(i, 2, temp, it);
  399. }
  400. },
  401. // 添加段落
  402. addParagraph(i) {
  403. this.form.prags.splice(i + 1, 0, {
  404. title: '',
  405. content: '',
  406. isReason: 0,
  407. position: [],
  408. text: ''
  409. });
  410. //添加段落光标自动落到新增的段落中
  411. setTimeout(() => {
  412. this.$refs.subForm[i + 1].$el
  413. .getElementsByClassName('el-input__inner')[0]
  414. .focus();
  415. });
  416. },
  417. delParagraph(i) {
  418. if (this.form.prags.length == 1) {
  419. this.warning('只剩一个段落,不能再删啦!');
  420. return;
  421. }
  422. this.showConfirmDialog('确定要删除该段落?', () => {
  423. this.form.prags.splice(i, 1);
  424. });
  425. },
  426. back() {
  427. this.$router.go(-1);
  428. },
  429. searchTerms(query) {
  430. if (!query.trim()) {
  431. this.form.terms = [];
  432. return;
  433. }
  434. //搜索术语列表
  435. this.showDrop = true;
  436. api.getAllConcept({ inputStr: query.trim(), types: [0] }).then(res => {
  437. this.showDrop = false;
  438. if (res.data.code === '0') {
  439. this.terms = res.data.data;
  440. } else {
  441. this.warning('数据获取失败');
  442. }
  443. });
  444. },
  445. mapStringToNum(str) {
  446. return str.split(',').map(it => {
  447. return +it;
  448. });
  449. },
  450. // 额外的表单检验
  451. formVal() {
  452. let positiontemp = this.form.prags.map(item => {
  453. return [...item.position];
  454. });
  455. let positionArr = positiontemp.reduce(function(a, b) {
  456. return a.concat(b);
  457. }); // 所有被选中的值集合
  458. // console.log(positionArr, 'positionArr');
  459. // console.log(this.showType, '当前页的显示类型');
  460. let isVisFlag = positionArr.some(item => item === 2);
  461. let isDiagFlag = positionArr.some(item => item === 3);
  462. // console.log(isVisFlag, 'isVisFlag');
  463. if (
  464. (this.showType == 3 || this.showType == 4 || this.showType == 5|| this.showType == 6) &&
  465. isVisFlag
  466. ) {
  467. //若医学术语为检验/检查,且内容类型选择了注意事项,此时“注意事项标题”是必填项
  468. this.$refs.groups.clearValidate();
  469. this.rules.titleChange.push({
  470. required: true,
  471. message: '请输入注意事项标题',
  472. trigger: 'change'
  473. });
  474. this.$refs.groups.validateField('titleChange');
  475. this.rules.titleChange = this.rules.titleChange.slice(0, 1);
  476. if (this.form.titleChange.trim() !== '') {
  477. // console.log('内容不为空');
  478. return true;
  479. } else {
  480. var div = this.$refs['elscrollbar'].$refs['wrap'];
  481. this.$nextTick(() => {
  482. div.scrollTop = 0;
  483. });
  484. return false;
  485. }
  486. // return;
  487. } else if (isDiagFlag && this.showType == 1) {
  488. // 若医学术语为诊断,且内容类型选择了临床路径,此时“临床路径标题”是必填项
  489. this.$refs.groups.clearValidate();
  490. this.rules.titleChange.push({
  491. required: true,
  492. message: '请输入临床路径标题',
  493. trigger: 'change'
  494. });
  495. this.$refs.groups.validateField('titleChange');
  496. this.rules.titleChange = this.rules.titleChange.slice(0, 1);
  497. if (this.form.titleChange.trim() !== '') {
  498. // console.log('内容不为空');
  499. return true;
  500. } else {
  501. var div = this.$refs['elscrollbar'].$refs['wrap'];
  502. this.$nextTick(() => {
  503. div.scrollTop = 0;
  504. });
  505. return false;
  506. }
  507. }
  508. },
  509. submitForm() {
  510. if (this.isSuccessUpload === 1) {
  511. this.warning('文件上传中,请稍等');
  512. return;
  513. }
  514. let flagVal = this.formVal(); // 额外的表单校验
  515. if (flagVal === false) return;
  516. //验证外层表单
  517. let goOn = true,
  518. it = null;
  519. let outIsVia = true; // 外层验证是否通过
  520. this.$refs.groups.validate(valid => {
  521. if (!valid) {
  522. goOn = false;
  523. outIsVia = false;
  524. return false;
  525. }
  526. });
  527. //验证段落表单
  528. let viewHeight = 0; // 定位到表单校验的高度
  529. let viewHeightArr = []; // 表单校验出错高度的所有数组
  530. if (this.form.typeId !== 82 && this.form.typeId !== 83) {
  531. for (let i = 0; i < this.$refs.subForm.length; i++) {
  532. it = this.$refs.subForm[i];
  533. viewHeight += it.$el.offsetHeight;
  534. it.$refs.form.validate(valid => {
  535. if (!valid) {
  536. goOn = false;
  537. viewHeightArr.push(viewHeight);
  538. }
  539. });
  540. }
  541. }
  542. // console.log(viewHeightArr,'viewHeightArr');
  543. if (!goOn) {
  544. var div = this.$refs['elscrollbar'].$refs['wrap'];
  545. if (outIsVia) {
  546. // 外层校验通过,跳转至下层校验具体位置
  547. this.$nextTick(() => {
  548. div.scrollTop = +viewHeightArr[0] - 150;
  549. });
  550. } else {
  551. // 外层校验没通过,页面滚动到顶部
  552. this.$nextTick(() => {
  553. div.scrollTop = 0;
  554. });
  555. }
  556. return;
  557. }
  558. //通过必填验证,提交保存
  559. const item = this.form.prags;
  560. let param = [];
  561. if (this.form.typeId === 82 || this.form.typeId === 83) {
  562. if (this.form.fileList.length === 0) {
  563. this.warning('文件未上传,不存储数据');
  564. return;
  565. }
  566. param.push(
  567. Object.assign(
  568. {},
  569. {
  570. position: this.form.typeId === 82 ? '8' : '9',
  571. conceptId: this.form.conceptId,
  572. title: this.form.fileTitle,
  573. orderNo: 0,
  574. content: JSON.stringify(this.form.fileList[0])
  575. }
  576. )
  577. );
  578. } else {
  579. let data = this.form.prags,
  580. tempArr = [],
  581. paramsAll = {},
  582. types = this.form.typeId;
  583. for (let i = 0; i < data.length; i++) {
  584. let obj = {};
  585. obj.content = data[i].content;
  586. obj.text = data[i].text;
  587. obj.conceptId = data[i].conceptId;
  588. obj.orderNo = i;
  589. obj.title = data[i].title;
  590. obj.contentType = data[i].position.join(',');
  591. tempArr.push(obj);
  592. }
  593. paramsAll.clinicalPathwayName = types == 1 ? this.form.titleChange : '';
  594. paramsAll.id = this.conceptId;
  595. paramsAll.name = this.form.name;
  596. paramsAll.noticeName = types == 3 || types == 4 || types == 5 || types == 6 ? this.form.titleChange : '';
  597. paramsAll.type = this.form.typeId;
  598. paramsAll.details = tempArr;
  599. param = paramsAll;
  600. }
  601. // this.showSaveDialog(param,'是否'+(this.isEdit?'修改':'保存')+'该静态知识?');
  602. if (!this.isEdit) {
  603. // 新增页面
  604. this.saveDisable = true;
  605. this.sendSaveOrEdit(param);
  606. return;
  607. }
  608. this.showSaveDialog(
  609. param,
  610. '<div><p style="color: #333333">确定保存修改内容?</p><p style="color: #D70A25">保存后将覆盖原有数据,且原有数据无法恢复。</p></div>'
  611. );
  612. },
  613. showSaveDialog(param, msg) {
  614. this.showConfirmDialog(msg, () => {
  615. this.saveDisable = true; //提交保存按钮不可点击,返回结果时才可点击,防止频繁发送请求
  616. this.sendSaveOrEdit(param);
  617. });
  618. },
  619. //保存编辑 接口
  620. sendSaveOrEdit(param) {
  621. api
  622. .saveTermPrompts(param)
  623. .then(res => {
  624. if (res.data.code === '0') {
  625. this.isSuccessUpload = 0; // 修改文件上传状态为0
  626. this.warning(res.data.msg || '保存成功', 'success');
  627. this.isSaveSuccess = true; // 保存成功,可正常退出
  628. //返回带搜索条件的首页
  629. this.$router.push({
  630. name: 'MedicinePrompt',
  631. params: Object.assign({}, this.$route.params, {
  632. currentPage: 1
  633. })
  634. });
  635. } else {
  636. this.warning(res.data.msg);
  637. }
  638. this.saveDisable = false;
  639. })
  640. .catch(err => {
  641. if (err.code === '900010001') {
  642. return false;
  643. }
  644. this.saveDisable = false;
  645. this.warning(err);
  646. });
  647. },
  648. // 弹出窗
  649. showConfirmDialog(msg, resolve) {
  650. this.$confirm(msg, '提示', {
  651. confirmButtonText: '确定',
  652. cancelButtonText: '取消',
  653. cancelButtonClass: 'cancel',
  654. confirmButtonClass: 'confirmBtn',
  655. dangerouslyUseHTMLString: true,
  656. type: 'warning'
  657. })
  658. .then(() => {
  659. resolve();
  660. })
  661. .catch(() => {});
  662. },
  663. warning(msg, type) {
  664. this.$message({
  665. showClose: true,
  666. message: msg,
  667. type: type || 'warning',
  668. duration:1000
  669. });
  670. },
  671. handleChange(file, fileList) {
  672. // if(fileList&&fileList[0]&&fileList[0].response&&fileList[0].response.code==='0'){
  673. // this.showUpLoad = false
  674. // this.showFileList = true
  675. // }else{
  676. // this.showUpLoad = true
  677. // this.showFileList = false
  678. // }
  679. // console.log(fileList,this.form.fileList,'aa')
  680. },
  681. handleSuccess(response, file, fileList) {
  682. if (response.code == '0') {
  683. this.showFileList = true;
  684. this.form.fileList = [];
  685. this.form.fileList.push({
  686. name: response.data.title,
  687. url: response.data.url,
  688. size: response.data.size
  689. });
  690. this.showUpLoad = false;
  691. if (!this.form.fileTitle) {
  692. this.form.fileTitle = response.data.title;
  693. }
  694. this.isSuccessUpload = 2; // 上传成功状态
  695. this.$refs.upload && this.$refs.upload.clearValidate(); // 清除校验
  696. } else {
  697. this.warning(response.msg || '上传失败');
  698. // this.form.fileList = []
  699. this.showUpLoad = true;
  700. this.showFileList = false;
  701. this.form.fileList = [];
  702. }
  703. },
  704. handleRemove(file, fileList) {
  705. this.showUpLoad = true;
  706. this.form.fileList = [];
  707. this.isSuccessUpload = 0;
  708. },
  709. handleBeforeUpLoad(file) {
  710. // 上传过程中 上传按钮 隐藏
  711. this.isSuccessUpload = 1; // 上传过程中
  712. this.showFileList = true; // 新增 进度条 显示
  713. this.$refs.upload && this.$refs.upload.clearValidate(); // 清除校验
  714. this.showUpLoad = false;
  715. if (file.size / 1024 / 1024 >= 500) {
  716. this.warning('文件上传失败,超出大小限制500MB');
  717. this.form.fileList = [];
  718. this.showConfirm = false;
  719. return false;
  720. } else {
  721. this.showConfirm = true;
  722. }
  723. },
  724. handlePreview(file) {},
  725. beforeRemove(file, fileList) {
  726. if (this.showConfirm) {
  727. return this.$confirm(`确定移除 ${file.name}?`, '', {
  728. cancelButtonClass: 'cacelBtn'
  729. });
  730. }
  731. }
  732. }
  733. };
  734. </script>
  735. <style lang="less">
  736. @import '../../less/common.less';
  737. .cell .el-button.delete:focus {
  738. color: red !important;
  739. }
  740. .topBack {
  741. top: 0;
  742. }
  743. .info-container {
  744. background: #fff;
  745. padding: 20px;
  746. margin: 70px 20px -20px 20px;
  747. .el-input__inner {
  748. width: 200px;
  749. }
  750. .el-form-item__label {
  751. text-align: left;
  752. }
  753. .add-prg .el-form-item {
  754. margin-bottom: 20px;
  755. }
  756. .el-form-item {
  757. margin-bottom: 8px !important;
  758. }
  759. }
  760. // .cancel span {
  761. // color: #22ccc8;
  762. // }
  763. .line {
  764. border-top: 1px #dcdfe6 solid;
  765. margin-bottom: 25px;
  766. margin-top: 25px;
  767. }
  768. .NoiseTemplateWrapper .info-container .el-input__inner {
  769. width: 250px;
  770. }
  771. // .NoiseTemplateWrapper .el-select .el-input .el-icon-circle-close{
  772. // display: inherit!important;
  773. // }
  774. .cacelBtn {
  775. color: #22ccc8 !important;
  776. }
  777. .upload-demo {
  778. width: 300px;
  779. /deep/.el-upload-list__item .el-icon-close-tip {
  780. display: none !important;
  781. }
  782. /deep/.el-upload-list__item .el-upload-list__item-name {
  783. max-width: 250px;
  784. white-space: nowrap;
  785. overflow: hidden;
  786. text-overflow: ellipsis;
  787. }
  788. /deep/ .focusing {
  789. // border: 1px solid transparent !important;
  790. outline: transparent !important;
  791. }
  792. }
  793. .uploadInfo {
  794. margin-top: -20px;
  795. color: #606266;
  796. }
  797. .tipInfo {
  798. position: absolute;
  799. // position: relative;
  800. line-height: 24px;
  801. top: -56px;
  802. left: 20px;
  803. // background-color: transparent;
  804. // color: #606266;
  805. padding: 3px 10px;
  806. border-radius: 4px;
  807. margin: 100px auto;
  808. background-color: #4d4d4d;
  809. text-align: center;
  810. color: #fff;
  811. font-size: 14px;
  812. }
  813. .tipInfo:before {
  814. content: '';
  815. display: block;
  816. position: absolute;
  817. // bottom: 9px;
  818. top: -10px;
  819. left: 18px;
  820. border-bottom: 6px solid #4d4d4d;
  821. border-top: 6px solid transparent;
  822. border-left: 6px solid transparent;
  823. border-right: 6px solid transparent;
  824. // border-right: 6px solid #4D4D4D;
  825. }
  826. .btn {
  827. text-align: right;
  828. padding-right: 20px;
  829. }
  830. .el-message-box {
  831. /deep/ .el-icon-warning {
  832. background-color: transparent !important;
  833. // display: none;
  834. }
  835. /deep/ .el-message-box__message {
  836. margin: 24px 0px;
  837. }
  838. // /deep/ .confirmBtn {
  839. // // position: relative;
  840. // // right: 240px !important;
  841. // // top: 0px;
  842. // background-color: #fff !important;
  843. // span {
  844. // color: #48c5d7 !important;
  845. // }
  846. // }
  847. /deep/ .cancel {
  848. background-color: #d7d7d7;
  849. border-color: transparent !important;
  850. span {
  851. color: #fff;
  852. }
  853. }
  854. }
  855. </style>