AddCombinQuestion.vue 6.7 KB

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