AddCombinQuestion.vue 6.7 KB

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