AddSimpleQuestion.vue 7.9 KB

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