AddIndeptLabel.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <div class="NoiseTemplateWrapper TemplateWrapper">
  3. <div class="groupTitle"><i
  4. class="el-icon-back"
  5. @click="back"
  6. ></i> {{txt}}</div>
  7. <PubIndeptTag
  8. @changeVal="changeVal"
  9. @changeSex="changeSex"
  10. @changeType="changeType"
  11. @validatePass="validatePass"
  12. :editData="editData"
  13. ref="submitForm"
  14. ></PubIndeptTag>
  15. <div class="main">
  16. <p class="title" v-if="dataPub.region2==1||dataPub.region2==2"> <i>*</i> 标签明细:<i style="margin-left:70px;color: #22ccc8; font-size: 12px;">所有选项必须都有或者都没有同“伴”/“无”标记</i></p>
  17. <SingleSelect v-if="dataPub.region2==1 || dataPub.region2==2 || dataPub.region2==11" :ascription="dataPub.region1" :sexType="dataPub.region7" :type="dataPub.region2" @pushValues="pushValues" :options="editData.questionDetailList"></SingleSelect>
  18. <div class="btn">
  19. <el-button
  20. type="primary"
  21. @click="submitForm"
  22. >确 定</el-button>
  23. </div>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. /**
  29. * dataPub.region2 判断底部显示哪些
  30. */
  31. import PubIndeptTag from './PubIndeptTag';
  32. import SingleSelect from './SingleSelect';
  33. import api from '@api/icss.js';
  34. import utils from '@api/utils.js';
  35. export default {
  36. name: 'NoiseTemplateWrapper',
  37. data() {
  38. return {
  39. txt:'独立标签维护--添加独立标签',
  40. dataPub: {}, //公用组件传的值都在这
  41. itemsTypes:[1,2], //有明细的类型
  42. editData:{}, //编辑数据
  43. form: {
  44. currentOrder: '0', //标签成文顺序
  45. },
  46. rules: {
  47. currentOrder: [
  48. { required: true, message: '选择标签成文顺序', trigger: 'change' }
  49. ]
  50. },
  51. options: [], //标签明细右侧操作数据
  52. }
  53. },
  54. beforeMount:function(){
  55. const {isEdit,data} = this.$route.params;
  56. if(isEdit){
  57. this.txt = '独立标签维护--修改独立标签'
  58. this.editData = data;
  59. }
  60. },
  61. computed: {
  62. newSign() {
  63. return this.dataPub.region2;
  64. },
  65. },
  66. watch: {
  67. newSign(nextVal, prevVal) {
  68. if (nextVal != prevVal) {
  69. this.form.currentOrder = '0'
  70. }
  71. },
  72. },
  73. methods: {
  74. back() { this.$router.go(-1) },
  75. changeVal(val) { //子组件数据改变传递到父组件
  76. this.dataPub = val
  77. console.log('公用组件传的值都在这', val)
  78. },
  79. changeSex(sex) { //性别改变,清空标签明细
  80. //console.log(sex)
  81. },
  82. changeType(type) { //填写单类型改变,标签明细左侧更新,右侧清空
  83. // console.log('type',type)
  84. this.options = [];
  85. },
  86. pushValues(its){
  87. this.options = its;
  88. },
  89. submitForm() { // 调用子组件的方法验证公用部分
  90. this.$refs.submitForm.submitForm('groups');
  91. },
  92. validatePass() { //验证成功回调,调取接口
  93. //仍需验证标签明细是否选择
  94. let isNull = true
  95. let options2 = []
  96. const opts = this.options;
  97. for (let i = 0; i < this.options.length; i++) {
  98. if(this.options[i].name.trim() != '') {
  99. isNull = false
  100. options2.push(this.options[i])
  101. }
  102. }
  103. this.options = options2;
  104. if(this.itemsTypes.includes(+this.dataPub.region2)&&isNull) {
  105. this.$message({
  106. message: '至少填一个选项',
  107. type: 'warning'
  108. });
  109. return;
  110. }
  111. let flag=true;
  112. if(opts[0].code){
  113. flag=opts.findIndex((it)=>{
  114. return !it.code;
  115. })==-1;
  116. }else{
  117. flag=opts.findIndex((it)=>{
  118. return it.code;
  119. })==-1;
  120. }
  121. if(!flag){
  122. this.$message({
  123. message: '所有选项必须都有或者都没有同“伴”/“无”标记',
  124. type: 'warning'
  125. });
  126. return;
  127. }
  128. if(this.dataPub.region8 >= this.dataPub.region9) {
  129. this.$message({
  130. message: '最小年龄不能大于或等于最大年龄',
  131. type: 'warning'
  132. });
  133. return;
  134. }
  135. const {isEdit,data} = this.$route.params;
  136. let param = {
  137. "questionWrapper": {
  138. "controlType": this.dataPub.region2, //控件类型(0:默认值 1:下拉单选 2:下拉多选 6:文本框 7:数字键盘文本框 99:联合推送)
  139. "id": isEdit?data.id:'', //新增id置空
  140. "type": this.dataPub.region1, //标签归属
  141. "tagType": 1, //标签类型
  142. "tagName": this.dataPub.region3, //系统名称
  143. "name": this.dataPub.region4, //界面名称
  144. "joint": this.dataPub.region5, //标签间的连接符
  145. // "subType": this.dataPub.region6, //0:可以,1:不可以(当项目检索) //这个字段暂时不用
  146. "sexType": this.dataPub.region7, //1:男,2:女,3:通用
  147. "ageBegin": this.dataPub.region8, //最小年龄
  148. "ageEnd": this.dataPub.region9, //最大年龄
  149. "textGenerate": this.form.currentOrder, //成文顺序 默认0
  150. "copyType": this.dataPub.region2 == 6 ? this.dataPub.region10 : (this.dataPub.region2 == 3 ? this.dataPub.region11 : ''), //是否复制
  151. "showAdd": 0, //是否显示加号血压
  152. "showInfo": 0,
  153. "labelPrefix":this.dataPub.prefix, //前缀
  154. "labelSuffix":this.dataPub.suffix, //后缀
  155. "minValue": this.dataPub.minNormalVal, //化验最小正常值
  156. "maxValue": this.dataPub.maxNormalVal, //化验最大正常值
  157. "questionDetails": this.options,
  158. "questionMappings": [], //映射关系,
  159. "formulaCode": isEdit?data.formulaCode : ''
  160. }
  161. };
  162. this.showSaveDialog(param);
  163. },
  164. showSaveDialog(param) {
  165. this.showConfirmDialog('是否保存该标签?', () => {
  166. api.saveOrUpdate(param).then((res) => {
  167. if (res.data.code === '0') {
  168. this.warning(res.data.msg || '保存成功', 'success');
  169. this.$router.push("/admin/LT-YXSJWH-DLLXBQWH");
  170. } else {
  171. this.warning(res.data.msg)
  172. }
  173. }).catch((err) => {
  174. this.warning(err);
  175. })
  176. });
  177. },
  178. showConfirmDialog(msg, resolve) {
  179. this.$alert(msg, '提示', {
  180. confirmButtonText: '确定',
  181. type: 'warning'
  182. }).then(() => {
  183. resolve();
  184. }).catch(() => {});
  185. },
  186. warning(msg, type) {
  187. this.$message({
  188. showClose: true,
  189. message: msg,
  190. type: type || 'warning'
  191. })
  192. },
  193. },
  194. components: {
  195. PubIndeptTag,
  196. SingleSelect
  197. }
  198. }
  199. </script>
  200. <style lang="less">
  201. @import "../../less/common.less";
  202. .NoiseTemplateWrapper {
  203. .groupTitle {
  204. background-color: #fff;
  205. height: 40px;
  206. line-height: 40px;
  207. padding-left: 20px;
  208. }
  209. .main {
  210. background-color: #fff;
  211. margin: 0 20px 20px;
  212. padding: 20px;
  213. border-top: 1px solid @icssBorder;
  214. box-sizing: border-box;
  215. font-size: 14px;
  216. color: #606266;
  217. .title {
  218. margin-bottom: 20px;
  219. i {
  220. color: #f56c6c;
  221. }
  222. }
  223. }
  224. .btn {
  225. text-align: right;
  226. }
  227. .order {
  228. margin-bottom: 20px;
  229. .el-input__inner {
  230. line-height: 30px;
  231. height: 30px;
  232. }
  233. }
  234. }
  235. </style>