AddCombinQuestion.vue 6.3 KB

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