AddSimpleQuestion.vue 8.0 KB

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