AddSimpleQuestion.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <div class="NoiseTemplateWrapper TemplateWrapper">
  3. <crumbs
  4. :title="txt"
  5. class="topBack"
  6. :param="param"
  7. linkTo="SimpleQuestion"
  8. ></crumbs>
  9. <PubIndeptQa
  10. @changeVal="changeVal"
  11. @validatePass="validatePass"
  12. qaType="1"
  13. :editData="editData"
  14. ref="submitForm"
  15. ></PubIndeptQa>
  16. <div class="main">
  17. <p class="title" v-if="dataPub.region2==1||dataPub.region2==2|| dataPub.region2==3|| dataPub.region2==11">
  18. 填写单明细:<span v-if="dataPub.region2==2">(互斥项与其他明细内容互斥,互斥项同时只可选择一个)</span>
  19. </p>
  20. <PubSelect
  21. v-if="dataPub.region2==1 || dataPub.region2==2 || dataPub.region2==3 || dataPub.region2==11"
  22. :ascription="dataPub.region1"
  23. :sexType="dataPub.region7"
  24. :type="dataPub.region2"
  25. @pushValues="pushValues"
  26. :options="editData.questionDetailList"></PubSelect>
  27. <div class="btn">
  28. <el-button
  29. type="primary"
  30. @click="submitForm"
  31. >确 定</el-button>
  32. </div>
  33. </div>
  34. </div>
  35. </template>
  36. <script>
  37. /**
  38. * dataPub.region2 判断底部显示哪些
  39. */
  40. import PubIndeptQa from './PubIndeptQa';
  41. import PubSelect from './PubSelect';
  42. import api from '@api/preTreat.js';
  43. import utils from '@api/utils.js';
  44. export default {
  45. name: 'addSimpleQuestion',
  46. data() {
  47. return {
  48. txt:'独立填写单维护-添加独立填写单',
  49. param:this.$route.params,
  50. imgList:[],
  51. dataPub: {}, //公用组件传的值都在这
  52. itemsTypes:[1,2], //有明细的类型
  53. editData:{}, //编辑数据
  54. options: [], //标签明细右侧操作数据
  55. }
  56. },
  57. beforeMount:function(){
  58. const {isEdit,data} = this.$route.params;
  59. if(isEdit){
  60. this.txt = '独立填写单维护-修改独立填写单';
  61. this.editData = data;
  62. }
  63. },
  64. methods: {
  65. changeVal(val) { //子组件数据改变传递到父组件
  66. this.dataPub = val;
  67. //console.log('公用组件传的值都在这', val);
  68. },
  69. changeSex() { //性别改变,清空填写单明细
  70. this.changeType();
  71. },
  72. changeType() { //填写单类型改变,标签明细左侧更新,右侧清空
  73. this.options = [];
  74. },
  75. pushValues(its){
  76. this.options = its;
  77. },
  78. submitForm() { // 调用子组件的方法验证公用部分
  79. this.$refs.submitForm.submitForm('groups');
  80. },
  81. validatePass() { //验证成功回调,调取接口
  82. //仍需验证填写单明细是否选择
  83. let isNull = false;
  84. let options2 = [];
  85. const opts = this.options;
  86. let pureName='',pureDesc = '';
  87. for (let i = 0; i < opts.length; i++) {
  88. pureName=opts[i].name.replace(/(\$\{number_\S*?\})|(\$\{input_\S*?\})/g,'');
  89. pureDesc = opts[i].description.replace(/(\$\{number_\S*?\})|(\$\{input_\S*?\})/g,'');
  90. if(pureName.length>30){
  91. this.warning('医生界面展示内容不能超过30个字');
  92. return ;
  93. }
  94. if(pureDesc.length>30){
  95. this.warning('患者界面展示内容不能超过30个字');
  96. return ;
  97. }
  98. if(opts[i].name.trim() != '') {
  99. options2.push(this.options[i]);
  100. }else if(opts[i].description.trim() != ''){ //患者填了,医生没填,提示医生必填
  101. isNull = true;
  102. }
  103. }
  104. if(this.itemsTypes.includes(+this.dataPub.region2)&&isNull) {
  105. this.warning('医生界面展示标准内容必填');
  106. return;
  107. }
  108. if(parseFloat(this.dataPub.region8) >= parseFloat(this.dataPub.region9)) {
  109. this.warning('最小年龄不能大于或等于最大年龄');
  110. return;
  111. }
  112. if(parseFloat(this.dataPub.minNormalVal) >= parseFloat(this.dataPub.maxNormalVal)) {
  113. this.warning('最小正常值不能大于或等于最大正常值');
  114. return;
  115. }
  116. this.options = options2;
  117. const {isEdit,data} = this.$route.params;
  118. let param = {
  119. "questionWrapper": {
  120. "controlType": this.dataPub.region2, //控件类型(0:默认值 1:下拉单选 2:下拉多选 6:文本框 7:数字键盘文本框 99:联合推送)
  121. "id": isEdit?data.id:'', //新增id置空
  122. "type": this.dataPub.region1, //填写单归属
  123. "tagType": 1, //独立填写单类型
  124. "tagName": this.dataPub.region3, //系统名称
  125. "name": this.dataPub.region4, //医生界面名称
  126. "description":this.dataPub.region5,
  127. "sexType": this.dataPub.region7, //1:男,2:女,3:通用
  128. "ageBegin": this.dataPub.region8, //最小年龄
  129. "ageEnd": this.dataPub.region9, //最大年龄
  130. "itemType" :this.dataPub.region12, //是否为主要内容
  131. "url":this.dataPub.region13, //上传图片
  132. "questionDetails": this.options, //明细项
  133. //"questionMappings": [], //映射关系,
  134. }
  135. };
  136. this.showSaveDialog(param);
  137. },
  138. showSaveDialog(param) {
  139. this.showConfirmDialog('是否保存该填写单?', () => {
  140. api.questionAdd(param).then((res) => {
  141. if (res.data.code === '0') {
  142. this.warning(res.data.msg || '保存成功', 'success');
  143. //返回带搜索条件的首页
  144. this.$router.push({name:"SimpleQuestion",params:Object.assign({},this.param,{currentPage:1})});
  145. } else {
  146. this.warning(res.data.msg)
  147. }
  148. }).catch((err) => {
  149. this.warning(err);
  150. })
  151. });
  152. },
  153. showConfirmDialog(msg, resolve) {
  154. this.$alert(msg, '提示', {
  155. confirmButtonText: '确定',
  156. type: 'warning'
  157. }).then(() => {
  158. resolve();
  159. }).catch(() => {});
  160. },
  161. warning(msg, type) {
  162. this.$message({
  163. showClose: true,
  164. message: msg,
  165. type: type || 'warning'
  166. })
  167. },
  168. },
  169. components: {
  170. PubIndeptQa,
  171. PubSelect
  172. }
  173. }
  174. </script>
  175. <style lang="less">
  176. @import "../../less/common.less";
  177. .NoiseTemplateWrapper {
  178. .groupTitle {
  179. background-color: #fff;
  180. height: 40px;
  181. line-height: 40px;
  182. padding-left: 20px;
  183. }
  184. .main {
  185. background-color: #fff;
  186. margin: 0 20px 20px;
  187. padding: 20px;
  188. border-top: 1px solid @icssBorder;
  189. box-sizing: border-box;
  190. font-size: 14px;
  191. color: #606266;
  192. .title {
  193. margin-bottom: 20px;
  194. i {
  195. color: #f56c6c;
  196. }
  197. }
  198. }
  199. .btn {
  200. text-align: right;
  201. }
  202. .order {
  203. margin-bottom: 20px;
  204. .el-input__inner {
  205. line-height: 30px;
  206. height: 30px;
  207. }
  208. }
  209. }
  210. .toast-cancel{
  211. color: #22ccc8 !important;
  212. // background: #22ccc8;
  213. }
  214. </style>