AddDevKnow.vue 27 KB

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