AddSimpleQuestion.vue 8.3 KB

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