AddSimpleQuestion.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. 填写单明细:
  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. beforeDestroy(){
  63. console.log(33333)
  64. this.options = [];
  65. },
  66. methods: {
  67. back() { this.$router.go(-1) },
  68. changeVal(val) { //子组件数据改变传递到父组件
  69. this.dataPub = val;
  70. //console.log('公用组件传的值都在这', val);
  71. },
  72. changeSex() { //性别改变,清空填写单明细
  73. this.changeType();
  74. },
  75. changeType() { //填写单类型改变,标签明细左侧更新,右侧清空
  76. this.options = [];
  77. },
  78. pushValues(its){
  79. this.options = its;
  80. },
  81. submitForm() { // 调用子组件的方法验证公用部分
  82. this.$refs.submitForm.submitForm('groups');
  83. },
  84. validatePass() { //验证成功回调,调取接口
  85. //仍需验证填写单明细是否选择
  86. let isNull = false;
  87. let options2 = [];
  88. const opts = this.options;
  89. for (let i = 0; i < this.options.length; i++) {
  90. if(this.options[i].name.trim() != '') {
  91. options2.push(this.options[i])
  92. }else if(this.options[i].description.trim() != ''){ //患者填了,医生没填,提示医生必填
  93. isNull = true;
  94. }
  95. }
  96. this.options = options2;
  97. if(this.itemsTypes.includes(+this.dataPub.region2)&&isNull) {
  98. this.warning('医生界面展示标准内容必填');
  99. return;
  100. }
  101. if(parseFloat(this.dataPub.region8) >= parseFloat(this.dataPub.region9)) {
  102. this.warning('最小年龄不能大于或等于最大年龄');
  103. return;
  104. }
  105. if(parseFloat(this.dataPub.minNormalVal) >= parseFloat(this.dataPub.maxNormalVal)) {
  106. this.warning('最小正常值不能大于或等于最大正常值');
  107. return;
  108. }
  109. const {isEdit,data} = this.$route.params;
  110. let param = {
  111. "questionWrapper": {
  112. "controlType": this.dataPub.region2, //控件类型(0:默认值 1:下拉单选 2:下拉多选 6:文本框 7:数字键盘文本框 99:联合推送)
  113. "id": isEdit?data.id:'', //新增id置空
  114. "type": this.dataPub.region1, //填写单归属
  115. "tagType": 1, //独立填写单类型
  116. "tagName": this.dataPub.region3, //系统名称
  117. "name": this.dataPub.region4, //医生界面名称
  118. "description":this.dataPub.region5,
  119. "sexType": this.dataPub.region7, //1:男,2:女,3:通用
  120. "ageBegin": this.dataPub.region8, //最小年龄
  121. "ageEnd": this.dataPub.region9, //最大年龄
  122. "itemType" :this.dataPub.region12, //是否为主要内容
  123. "url":this.dataPub.region13, //上传图片
  124. "questionDetails": this.options, //明细项
  125. //"questionMappings": [], //映射关系,
  126. }
  127. };
  128. this.showSaveDialog(param);
  129. },
  130. showSaveDialog(param) {
  131. this.showConfirmDialog('是否保存该填写单?', () => {
  132. api.questionAdd(param).then((res) => {
  133. if (res.data.code === '0') {
  134. this.warning(res.data.msg || '保存成功', 'success');
  135. this.$router.push("/admin/LT-YWZSJWH-DLTXDWH");
  136. } else {
  137. this.warning(res.data.msg)
  138. }
  139. }).catch((err) => {
  140. this.warning(err);
  141. })
  142. });
  143. },
  144. showConfirmDialog(msg, resolve) {
  145. this.$alert(msg, '提示', {
  146. confirmButtonText: '确定',
  147. type: 'warning'
  148. }).then(() => {
  149. resolve();
  150. }).catch(() => {});
  151. },
  152. warning(msg, type) {
  153. this.$message({
  154. showClose: true,
  155. message: msg,
  156. type: type || 'warning'
  157. })
  158. },
  159. },
  160. components: {
  161. PubIndeptQa,
  162. PubSelect
  163. }
  164. }
  165. </script>
  166. <style lang="less">
  167. @import "../../less/common.less";
  168. .NoiseTemplateWrapper {
  169. .groupTitle {
  170. background-color: #fff;
  171. height: 40px;
  172. line-height: 40px;
  173. padding-left: 20px;
  174. }
  175. .main {
  176. background-color: #fff;
  177. margin: 0 20px 20px;
  178. padding: 20px;
  179. border-top: 1px solid @icssBorder;
  180. box-sizing: border-box;
  181. font-size: 14px;
  182. color: #606266;
  183. .title {
  184. margin-bottom: 20px;
  185. i {
  186. color: #f56c6c;
  187. }
  188. }
  189. }
  190. .btn {
  191. text-align: right;
  192. }
  193. .order {
  194. margin-bottom: 20px;
  195. .el-input__inner {
  196. line-height: 30px;
  197. height: 30px;
  198. }
  199. }
  200. }
  201. .toast-cancel{
  202. color: #22ccc8 !important;
  203. // background: #22ccc8;
  204. }
  205. </style>