AddMedicinePrompt.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867
  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.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. addParagraph(i) {
  402. this.form.prags.splice(i + 1, 0, {
  403. title: '',
  404. content: '',
  405. isReason: 0,
  406. position: [],
  407. text: ''
  408. });
  409. //添加段落光标自动落到新增的段落中
  410. setTimeout(() => {
  411. this.$refs.subForm[i + 1].$el
  412. .getElementsByClassName('el-input__inner')[0]
  413. .focus();
  414. });
  415. },
  416. delParagraph(i) {
  417. if (this.form.prags.length == 1) {
  418. this.warning('只剩一个段落,不能再删啦!');
  419. return;
  420. }
  421. this.showConfirmDialog('确定要删除该段落?', () => {
  422. this.form.prags.splice(i, 1);
  423. });
  424. },
  425. back() {
  426. this.$router.go(-1);
  427. },
  428. searchTerms(query) {
  429. if (!query.trim()) {
  430. this.form.terms = [];
  431. return;
  432. }
  433. //搜索术语列表
  434. this.showDrop = true;
  435. api.getAllConcept({ inputStr: query.trim(), types: [0] }).then(res => {
  436. this.showDrop = false;
  437. if (res.data.code === '0') {
  438. this.terms = res.data.data;
  439. } else {
  440. this.warning('数据获取失败');
  441. }
  442. });
  443. },
  444. mapStringToNum(str) {
  445. return str.split(',').map(it => {
  446. return +it;
  447. });
  448. },
  449. // 额外的表单检验
  450. formVal() {
  451. let positiontemp = this.form.prags.map(item => {
  452. return [...item.position];
  453. });
  454. let positionArr = positiontemp.reduce(function(a, b) {
  455. return a.concat(b);
  456. }); // 所有被选中的值集合
  457. // console.log(positionArr, 'positionArr');
  458. // console.log(this.showType, '当前页的显示类型');
  459. let isVisFlag = positionArr.some(item => item === 2);
  460. let isDiagFlag = positionArr.some(item => item === 3);
  461. // console.log(isVisFlag, 'isVisFlag');
  462. if (
  463. (this.showType == 3 || this.showType == 4 || this.showType == 5|| this.showType == 6) &&
  464. isVisFlag
  465. ) {
  466. //若医学术语为检验/检查,且内容类型选择了注意事项,此时“注意事项标题”是必填项
  467. this.$refs.groups.clearValidate();
  468. this.rules.titleChange.push({
  469. required: true,
  470. message: '请输入注意事项标题',
  471. trigger: 'change'
  472. });
  473. this.$refs.groups.validateField('titleChange');
  474. this.rules.titleChange = this.rules.titleChange.slice(0, 1);
  475. if (this.form.titleChange.trim() !== '') {
  476. // console.log('内容不为空');
  477. return true;
  478. } else {
  479. var div = this.$refs['elscrollbar'].$refs['wrap'];
  480. this.$nextTick(() => {
  481. div.scrollTop = 0;
  482. });
  483. return false;
  484. }
  485. // return;
  486. } else if (isDiagFlag && this.showType == 1) {
  487. // 若医学术语为诊断,且内容类型选择了临床路径,此时“临床路径标题”是必填项
  488. this.$refs.groups.clearValidate();
  489. this.rules.titleChange.push({
  490. required: true,
  491. message: '请输入临床路径标题',
  492. trigger: 'change'
  493. });
  494. this.$refs.groups.validateField('titleChange');
  495. this.rules.titleChange = this.rules.titleChange.slice(0, 1);
  496. if (this.form.titleChange.trim() !== '') {
  497. // console.log('内容不为空');
  498. return true;
  499. } else {
  500. var div = this.$refs['elscrollbar'].$refs['wrap'];
  501. this.$nextTick(() => {
  502. div.scrollTop = 0;
  503. });
  504. return false;
  505. }
  506. }
  507. },
  508. submitForm() {
  509. if (this.isSuccessUpload === 1) {
  510. this.warning('文件上传中,请稍等');
  511. return;
  512. }
  513. let flagVal = this.formVal(); // 额外的表单校验
  514. if (flagVal === false) return;
  515. //验证外层表单
  516. let goOn = true,
  517. it = null;
  518. let outIsVia = true; // 外层验证是否通过
  519. this.$refs.groups.validate(valid => {
  520. if (!valid) {
  521. goOn = false;
  522. outIsVia = false;
  523. return false;
  524. }
  525. });
  526. //验证段落表单
  527. let viewHeight = 0; // 定位到表单校验的高度
  528. let viewHeightArr = []; // 表单校验出错高度的所有数组
  529. if (this.form.typeId !== 82 && this.form.typeId !== 83) {
  530. for (let i = 0; i < this.$refs.subForm.length; i++) {
  531. it = this.$refs.subForm[i];
  532. viewHeight += it.$el.offsetHeight;
  533. it.$refs.form.validate(valid => {
  534. if (!valid) {
  535. goOn = false;
  536. viewHeightArr.push(viewHeight);
  537. }
  538. });
  539. }
  540. }
  541. // console.log(viewHeightArr,'viewHeightArr');
  542. if (!goOn) {
  543. var div = this.$refs['elscrollbar'].$refs['wrap'];
  544. if (outIsVia) {
  545. // 外层校验通过,跳转至下层校验具体位置
  546. this.$nextTick(() => {
  547. div.scrollTop = +viewHeightArr[0] - 150;
  548. });
  549. } else {
  550. // 外层校验没通过,页面滚动到顶部
  551. this.$nextTick(() => {
  552. div.scrollTop = 0;
  553. });
  554. }
  555. return;
  556. }
  557. //通过必填验证,提交保存
  558. const item = this.form.prags;
  559. let param = [];
  560. if (this.form.typeId === 82 || this.form.typeId === 83) {
  561. if (this.form.fileList.length === 0) {
  562. this.warning('文件未上传,不存储数据');
  563. return;
  564. }
  565. param.push(
  566. Object.assign(
  567. {},
  568. {
  569. position: this.form.typeId === 82 ? '8' : '9',
  570. conceptId: this.form.conceptId,
  571. title: this.form.fileTitle,
  572. orderNo: 0,
  573. content: JSON.stringify(this.form.fileList[0])
  574. }
  575. )
  576. );
  577. } else {
  578. let data = this.form.prags,
  579. tempArr = [],
  580. paramsAll = {},
  581. types = this.form.typeId;
  582. for (let i = 0; i < data.length; i++) {
  583. let obj = {};
  584. obj.content = data[i].content;
  585. obj.text = data[i].text;
  586. obj.conceptId = data[i].conceptId;
  587. obj.orderNo = i;
  588. obj.title = data[i].title;
  589. obj.contentType = data[i].position.join(',');
  590. tempArr.push(obj);
  591. }
  592. paramsAll.clinicalPathwayName = types == 1 ? this.form.titleChange : '';
  593. paramsAll.id = this.conceptId;
  594. paramsAll.name = this.form.name;
  595. paramsAll.noticeName = types == 3 || types == 4 || types == 5 || types == 6 ? this.form.titleChange : '';
  596. paramsAll.type = this.form.typeId;
  597. paramsAll.details = tempArr;
  598. param = paramsAll;
  599. }
  600. // this.showSaveDialog(param,'是否'+(this.isEdit?'修改':'保存')+'该静态知识?');
  601. if (!this.isEdit) {
  602. // 新增页面
  603. this.saveDisable = true;
  604. this.sendSaveOrEdit(param);
  605. return;
  606. }
  607. this.showSaveDialog(
  608. param,
  609. '<div><p style="color: #333333">确定保存修改内容?</p><p style="color: #D70A25">保存后将覆盖原有数据,且原有数据无法恢复。</p></div>'
  610. );
  611. },
  612. showSaveDialog(param, msg) {
  613. this.showConfirmDialog(msg, () => {
  614. this.saveDisable = true; //提交保存按钮不可点击,返回结果时才可点击,防止频繁发送请求
  615. this.sendSaveOrEdit(param);
  616. });
  617. },
  618. //保存编辑 接口
  619. sendSaveOrEdit(param) {
  620. api
  621. .saveTermPrompts(param)
  622. .then(res => {
  623. if (res.data.code === '0') {
  624. this.isSuccessUpload = 0; // 修改文件上传状态为0
  625. this.warning(res.data.msg || '保存成功', 'success');
  626. this.isSaveSuccess = true; // 保存成功,可正常退出
  627. //返回带搜索条件的首页
  628. this.$router.push({
  629. name: 'MedicinePrompt',
  630. params: Object.assign({}, this.$route.params, {
  631. currentPage: 1
  632. })
  633. });
  634. } else {
  635. this.warning(res.data.msg);
  636. }
  637. this.saveDisable = false;
  638. })
  639. .catch(err => {
  640. if (err.code === '900010001') {
  641. return false;
  642. }
  643. this.saveDisable = false;
  644. this.warning(err);
  645. });
  646. },
  647. // 弹出窗
  648. showConfirmDialog(msg, resolve) {
  649. this.$confirm(msg, '提示', {
  650. confirmButtonText: '确定',
  651. cancelButtonText: '取消',
  652. cancelButtonClass: 'cancel',
  653. confirmButtonClass: 'confirmBtn',
  654. dangerouslyUseHTMLString: true,
  655. type: 'warning'
  656. })
  657. .then(() => {
  658. resolve();
  659. })
  660. .catch(() => {});
  661. },
  662. warning(msg, type) {
  663. this.$message({
  664. showClose: true,
  665. message: msg,
  666. type: type || 'warning',
  667. duration:1000
  668. });
  669. },
  670. handleChange(file, fileList) {
  671. // if(fileList&&fileList[0]&&fileList[0].response&&fileList[0].response.code==='0'){
  672. // this.showUpLoad = false
  673. // this.showFileList = true
  674. // }else{
  675. // this.showUpLoad = true
  676. // this.showFileList = false
  677. // }
  678. // console.log(fileList,this.form.fileList,'aa')
  679. },
  680. handleSuccess(response, file, fileList) {
  681. if (response.code == '0') {
  682. this.showFileList = true;
  683. this.form.fileList = [];
  684. this.form.fileList.push({
  685. name: response.data.title,
  686. url: response.data.url,
  687. size: response.data.size
  688. });
  689. this.showUpLoad = false;
  690. if (!this.form.fileTitle) {
  691. this.form.fileTitle = response.data.title;
  692. }
  693. this.isSuccessUpload = 2; // 上传成功状态
  694. this.$refs.upload && this.$refs.upload.clearValidate(); // 清除校验
  695. } else {
  696. this.warning(response.msg || '上传失败');
  697. // this.form.fileList = []
  698. this.showUpLoad = true;
  699. this.showFileList = false;
  700. this.form.fileList = [];
  701. }
  702. },
  703. handleRemove(file, fileList) {
  704. this.showUpLoad = true;
  705. this.form.fileList = [];
  706. this.isSuccessUpload = 0;
  707. },
  708. handleBeforeUpLoad(file) {
  709. // 上传过程中 上传按钮 隐藏
  710. this.isSuccessUpload = 1; // 上传过程中
  711. this.showFileList = true; // 新增 进度条 显示
  712. this.$refs.upload && this.$refs.upload.clearValidate(); // 清除校验
  713. this.showUpLoad = false;
  714. if (file.size / 1024 / 1024 >= 500) {
  715. this.warning('文件上传失败,超出大小限制500MB');
  716. this.form.fileList = [];
  717. this.showConfirm = false;
  718. return false;
  719. } else {
  720. this.showConfirm = true;
  721. }
  722. },
  723. handlePreview(file) {},
  724. beforeRemove(file, fileList) {
  725. if (this.showConfirm) {
  726. return this.$confirm(`确定移除 ${file.name}?`, '', {
  727. cancelButtonClass: 'cacelBtn'
  728. });
  729. }
  730. }
  731. }
  732. };
  733. </script>
  734. <style lang="less">
  735. @import '../../less/common.less';
  736. .cell .el-button.delete:focus {
  737. color: red !important;
  738. }
  739. .topBack {
  740. top: 0;
  741. }
  742. .info-container {
  743. background: #fff;
  744. padding: 20px;
  745. margin: 70px 20px -20px 20px;
  746. .el-input__inner {
  747. width: 200px;
  748. }
  749. .el-form-item__label {
  750. text-align: left;
  751. }
  752. .add-prg .el-form-item {
  753. margin-bottom: 20px;
  754. }
  755. .el-form-item {
  756. margin-bottom: 8px !important;
  757. }
  758. }
  759. // .cancel span {
  760. // color: #22ccc8;
  761. // }
  762. .line {
  763. border-top: 1px #dcdfe6 solid;
  764. margin-bottom: 25px;
  765. margin-top: 25px;
  766. }
  767. .NoiseTemplateWrapper .info-container .el-input__inner {
  768. width: 250px;
  769. }
  770. // .NoiseTemplateWrapper .el-select .el-input .el-icon-circle-close{
  771. // display: inherit!important;
  772. // }
  773. .cacelBtn {
  774. color: #22ccc8 !important;
  775. }
  776. .upload-demo {
  777. width: 300px;
  778. /deep/.el-upload-list__item .el-icon-close-tip {
  779. display: none !important;
  780. }
  781. /deep/.el-upload-list__item .el-upload-list__item-name {
  782. max-width: 250px;
  783. white-space: nowrap;
  784. overflow: hidden;
  785. text-overflow: ellipsis;
  786. }
  787. /deep/ .focusing {
  788. // border: 1px solid transparent !important;
  789. outline: transparent !important;
  790. }
  791. }
  792. .uploadInfo {
  793. margin-top: -20px;
  794. color: #606266;
  795. }
  796. .tipInfo {
  797. position: absolute;
  798. // position: relative;
  799. line-height: 24px;
  800. top: -56px;
  801. left: 20px;
  802. // background-color: transparent;
  803. // color: #606266;
  804. padding: 3px 10px;
  805. border-radius: 4px;
  806. margin: 100px auto;
  807. background-color: #4d4d4d;
  808. text-align: center;
  809. color: #fff;
  810. font-size: 14px;
  811. }
  812. .tipInfo:before {
  813. content: '';
  814. display: block;
  815. position: absolute;
  816. // bottom: 9px;
  817. top: -10px;
  818. left: 18px;
  819. border-bottom: 6px solid #4d4d4d;
  820. border-top: 6px solid transparent;
  821. border-left: 6px solid transparent;
  822. border-right: 6px solid transparent;
  823. // border-right: 6px solid #4D4D4D;
  824. }
  825. .btn {
  826. text-align: right;
  827. padding-right: 20px;
  828. }
  829. .el-message-box {
  830. /deep/ .el-icon-warning {
  831. background-color: transparent !important;
  832. // display: none;
  833. }
  834. /deep/ .el-message-box__message {
  835. margin: 24px 0px;
  836. }
  837. // /deep/ .confirmBtn {
  838. // // position: relative;
  839. // // right: 240px !important;
  840. // // top: 0px;
  841. // background-color: #fff !important;
  842. // span {
  843. // color: #48c5d7 !important;
  844. // }
  845. // }
  846. /deep/ .cancel {
  847. background-color: #d7d7d7;
  848. border-color: transparent !important;
  849. span {
  850. color: #fff;
  851. }
  852. }
  853. }
  854. </style>