AddSimpleQuestion.vue 7.3 KB

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