AddCombinQuestion.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <div class="NoiseTemplateWrapper TemplateWrapper">
  3. <crumbs
  4. :title="txt"
  5. class="topBack"
  6. linkTo="/admin/LT-YWZSJWH-ZHTXDWH"
  7. ></crumbs>
  8. <PubIndeptQa
  9. @changeVal="changeVal"
  10. @changeSex="changeSex"
  11. @changeType="changeType"
  12. @validatePass="validatePass"
  13. qaType="2"
  14. :editData="editData"
  15. ref="submitForm"
  16. ></PubIndeptQa>
  17. <div class="main">
  18. <p class="title">
  19. 填写单明细:
  20. </p>
  21. <QuestionTagGroup :ascription="dataPub.region1" :sexType="dataPub.region7" :type="dataPub.region2" @changeActionData="pushValues" :options="editData.questionMapping"></QuestionTagGroup>
  22. <div class="btn">
  23. <el-button
  24. type="primary"
  25. @click="submitForm"
  26. >确 定</el-button>
  27. </div>
  28. </div>
  29. </div>
  30. </template>
  31. <script>
  32. /**
  33. * dataPub.region2 判断底部显示哪些
  34. */
  35. import PubIndeptQa from './PubIndeptQa';
  36. import QuestionTagGroup from './QuestionTagGroup';
  37. import api from '@api/preTreat.js';
  38. import utils from '@api/utils.js';
  39. export default {
  40. name: 'addCombinQuestion',
  41. data() {
  42. return {
  43. txt:'组合填写单维护-添加组合填写单',
  44. imgList:[],
  45. dataPub: {}, //公用组件传的值都在这
  46. itemsTypes:[1,2], //有明细的类型
  47. editData:{}, //编辑数据
  48. options: [], //标签明细右侧操作数据
  49. }
  50. },
  51. beforeMount:function(){
  52. const {isEdit,data} = this.$route.params;
  53. if(isEdit){
  54. this.txt = '组合填写单维护-修改组合填写单';
  55. this.editData = data;
  56. }
  57. },
  58. methods: {
  59. back() { this.$router.go(-1) },
  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:0
  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. //"questionDetails": this.options, //明细项
  110. "questionMappings": this.options, //映射关系,
  111. }
  112. };
  113. this.showSaveDialog(param);
  114. },
  115. showSaveDialog(param) {
  116. this.showConfirmDialog('是否保存该填写单?', () => {
  117. api.questionAdd(param).then((res) => {
  118. if (res.data.code === '0') {
  119. this.warning(res.data.msg || '保存成功', 'success');
  120. this.$router.push("/admin/LT-YWZSJWH-ZHTXDWH");
  121. } else {
  122. this.warning(res.data.msg)
  123. }
  124. }).catch((err) => {
  125. this.warning(err);
  126. })
  127. });
  128. },
  129. showConfirmDialog(msg, resolve) {
  130. this.$alert(msg, '提示', {
  131. confirmButtonText: '确定',
  132. type: 'warning'
  133. }).then(() => {
  134. resolve();
  135. }).catch(() => {});
  136. },
  137. warning(msg, type) {
  138. this.$message({
  139. showClose: true,
  140. message: msg,
  141. type: type || 'warning'
  142. })
  143. },
  144. },
  145. components: {
  146. PubIndeptQa,
  147. QuestionTagGroup
  148. }
  149. }
  150. </script>
  151. <style lang="less">
  152. @import "../../less/common.less";
  153. .NoiseTemplateWrapper {
  154. .groupTitle {
  155. background-color: #fff;
  156. height: 40px;
  157. line-height: 40px;
  158. padding-left: 20px;
  159. }
  160. .main {
  161. background-color: #fff;
  162. margin: 0 20px 20px;
  163. padding: 20px;
  164. border-top: 1px solid @icssBorder;
  165. box-sizing: border-box;
  166. font-size: 14px;
  167. color: #606266;
  168. .title {
  169. margin-bottom: 20px;
  170. i {
  171. color: #f56c6c;
  172. }
  173. }
  174. }
  175. .btn {
  176. text-align: right;
  177. }
  178. .order {
  179. margin-bottom: 20px;
  180. .el-input__inner {
  181. line-height: 30px;
  182. height: 30px;
  183. }
  184. }
  185. }
  186. .toast-cancel{
  187. color: #22ccc8 !important;
  188. // background: #22ccc8;
  189. }
  190. </style>