AddIndeptLabel.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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> 标签明细:</p>
  17. <SingleSelect v-if="dataPub.region2==1 || dataPub.region2==2" :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)
  84. },
  85. pushValues(its){
  86. this.options = its;
  87. },
  88. submitForm() { // 调用子组件的方法验证公用部分
  89. this.$refs.submitForm.submitForm('groups');
  90. },
  91. validatePass() { //验证成功回调,调取接口
  92. //仍需验证标签明细是否选择
  93. let isNull = true
  94. let options2 = []
  95. for (let i = 0; i < this.options.length; i++) {
  96. if(this.options[i].name.trim() != '') {
  97. isNull = false
  98. options2.push(this.options[i])
  99. }
  100. }
  101. this.options = options2;
  102. if(this.itemsTypes.includes(+this.dataPub.region2)&&isNull) {
  103. this.$message({
  104. message: '至少填一个选项',
  105. type: 'warning'
  106. });
  107. return;
  108. }
  109. if(this.dataPub.region8 > this.dataPub.region9) {
  110. this.$message({
  111. message: '最小年龄不能大于最大年龄',
  112. type: 'warning'
  113. });
  114. return;
  115. }
  116. const {isEdit,data} = this.$route.params;
  117. let param = {
  118. "questionWrapper": {
  119. "controlType": this.dataPub.region2, //控件类型(0:默认值 1:下拉单选 2:下拉多选 6:文本框 7:数字键盘文本框 99:联合推送)
  120. "id": isEdit?data.id:'', //新增id置空
  121. "type": this.dataPub.region1, //标签归属
  122. "tagType": 1, //标签类型
  123. "tagName": this.dataPub.region3, //系统名称
  124. "name": this.dataPub.region4, //界面名称
  125. "joint": this.dataPub.region5, //标签间的连接符
  126. "subType": this.dataPub.region6, //0:可以,1:不可以(当项目检索)
  127. "sexType": this.dataPub.region7, //1:男,2:女,3:通用
  128. "ageBegin": this.dataPub.region8, //最小年龄
  129. "ageEnd": this.dataPub.region9, //最大年龄
  130. "textGenerate": this.form.currentOrder, //成文顺序 默认0
  131. "copyType": this.dataPub.region2 == 6 ? this.dataPub.region10 : (this.dataPub.region2 == 3 ? this.dataPub.region11 : ''), //是否复制
  132. "showAdd": 0, //是否显示加号血压
  133. "showInfo": 0,
  134. "labelPrefix":this.dataPub.prefix, //前缀
  135. "labelSuffix":this.dataPub.suffix, //后缀
  136. "minValue": this.dataPub.minNormalVal, //化验最小正常值
  137. "maxValue": this.dataPub.maxNormalVal, //化验最大正常值
  138. "questionDetails": this.options,
  139. "questionMappings": [], //映射关系,
  140. "formulaCode": isEdit?data.formulaCode : ''
  141. }
  142. };
  143. this.showSaveDialog(param);
  144. },
  145. showSaveDialog(param) {
  146. this.showConfirmDialog('是否保存该标签?', () => {
  147. api.saveOrUpdate(param).then((res) => {
  148. if (res.data.code === '0') {
  149. this.warning(res.data.msg || '保存成功', 'success');
  150. this.$router.push("/admin/LT-YXSJWH-DLLXBQWH");
  151. } else {
  152. this.warning(res.data.msg)
  153. }
  154. }).catch((err) => {
  155. this.warning(err);
  156. })
  157. });
  158. },
  159. showConfirmDialog(msg, resolve) {
  160. this.$alert(msg, '提示', {
  161. confirmButtonText: '确定',
  162. type: 'warning'
  163. }).then(() => {
  164. resolve();
  165. }).catch(() => {});
  166. },
  167. warning(msg, type) {
  168. this.$message({
  169. showClose: true,
  170. message: msg,
  171. type: type || 'warning'
  172. })
  173. },
  174. },
  175. components: {
  176. PubIndeptTag,
  177. SingleSelect
  178. }
  179. }
  180. </script>
  181. <style lang="less">
  182. @import "../../less/common.less";
  183. .NoiseTemplateWrapper {
  184. .groupTitle {
  185. background-color: #fff;
  186. height: 40px;
  187. line-height: 40px;
  188. padding-left: 20px;
  189. }
  190. .main {
  191. background-color: #fff;
  192. margin: 0 20px 20px;
  193. padding: 20px;
  194. border-top: 1px solid @icssBorder;
  195. box-sizing: border-box;
  196. font-size: 14px;
  197. color: #606266;
  198. .title {
  199. margin-bottom: 20px;
  200. i {
  201. color: #f56c6c;
  202. }
  203. }
  204. }
  205. .btn {
  206. text-align: right;
  207. }
  208. .order {
  209. margin-bottom: 20px;
  210. .el-input__inner {
  211. line-height: 30px;
  212. height: 30px;
  213. }
  214. }
  215. }
  216. </style>