AddSimpleQuestion.vue 7.1 KB

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