AddIndeptLabel.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div class="NoiseTemplateWrapper TemplateWrapper">
  3. <div class="groupTitle"><i
  4. class="el-icon-back"
  5. @click="back"
  6. ></i> 独立标签维护--添加独立标签</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||dataPub.region2==99"> <i>*</i> 标签明细:</p>
  17. <SingleSelect v-if="dataPub.region2==1" :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. dataPub: {}, //公用组件传的值都在这
  40. itemsTypes:[1,2,99], //有明细的类型
  41. editData:{}, //编辑数据
  42. form: {
  43. currentOrder: '0', //标签成文顺序
  44. },
  45. rules: {
  46. currentOrder: [
  47. { required: true, message: '选择标签成文顺序', trigger: 'change' }
  48. ]
  49. },
  50. options: [], //标签明细右侧操作数据
  51. }
  52. },
  53. beforeMount:function(){
  54. const {isEdit,data} = this.$route.params;
  55. if(isEdit){
  56. this.editData = data;
  57. }
  58. },
  59. computed: {
  60. newSign() {
  61. return this.dataPub.region2;
  62. },
  63. },
  64. watch: {
  65. newSign(nextVal, prevVal) {
  66. if (nextVal != prevVal) {
  67. this.form.currentOrder = '0'
  68. }
  69. },
  70. },
  71. methods: {
  72. back() { this.$router.go(-1) },
  73. changeVal(val) { //子组件数据改变传递到父组件
  74. this.dataPub = val
  75. //console.log('公用组件传的值都在这', val)
  76. },
  77. changeSex(sex) { //性别改变,清空标签明细
  78. //console.log(sex)
  79. },
  80. changeType(type) { //填写单类型改变,标签明细左侧更新,右侧清空
  81. //console.log(type)
  82. },
  83. pushValues(its){
  84. this.options = its;
  85. },
  86. submitForm() { // 调用子组件的方法验证公用部分
  87. this.$refs.submitForm.submitForm('groups');
  88. },
  89. validatePass() { //验证成功回调,调取接口
  90. //仍需验证标签明细是否选择
  91. if (this.itemsTypes.includes(+this.dataPub.region2)&&this.options.length==0) {
  92. this.$message({
  93. message: '至少填一个选项',
  94. type: 'warning'
  95. });
  96. return;
  97. }
  98. const {isEdit,data} = this.$route.params;
  99. let param = {
  100. "questionWrapper": {
  101. "controlType": this.dataPub.region2, //控件类型(0:默认值 1:下拉单选 2:下拉多选 6:文本框 7:数字键盘文本框 99:联合推送)
  102. "id": isEdit?data.id:'', //新增id置空
  103. "type": this.dataPub.region1, //标签归属
  104. "tagType": 1, //标签类型
  105. "tagName": this.dataPub.region3, //系统名称
  106. "name": this.dataPub.region4, //界面名称
  107. "joint": this.dataPub.region5, //标签间的连接符
  108. "subType": this.dataPub.region6, //0:可以,1:不可以(当项目检索)
  109. "sexType": this.dataPub.region7, //1:男,2:女,3:通用
  110. "ageBegin": this.dataPub.region8, //最小年龄
  111. "ageEnd": this.dataPub.region9, //最大年龄
  112. "textGenerate": this.form.currentOrder, //成文顺序 默认0
  113. "copyType": this.dataPub.region2 == 6 ? this.dataPub.region10 : (this.dataPub.region2 == 3 ? this.dataPub.region11 : ''), //是否复制
  114. "showAdd": 0, //是否显示加号血压
  115. "showInfo": 0,
  116. "labelPrefix":this.dataPub.prefix, //前缀
  117. "labelSuffix":this.dataPub.suffix, //后缀
  118. "questionDetails": this.options,
  119. "questionMappings": [] //映射关系,
  120. }
  121. };
  122. this.showSaveDialog(param);
  123. },
  124. showSaveDialog(param) {
  125. this.showConfirmDialog('是否保存该标签?', () => {
  126. api.saveOrUpdate(param).then((res) => {
  127. if (res.data.code === '0') {
  128. this.warning(res.data.msg || '保存成功', 'success');
  129. this.$router.push("/admin/LT-YXSJWH-DLLXBQWH");
  130. } else {
  131. this.warning(res.data.msg)
  132. }
  133. }).catch((err) => {
  134. this.warning(err);
  135. })
  136. });
  137. },
  138. showConfirmDialog(msg, resolve) {
  139. this.$alert(msg, '提示', {
  140. confirmButtonText: '确定',
  141. type: 'warning'
  142. }).then(() => {
  143. resolve();
  144. }).catch(() => {});
  145. },
  146. warning(msg, type) {
  147. this.$message({
  148. showClose: true,
  149. message: msg,
  150. type: type || 'warning'
  151. })
  152. },
  153. },
  154. components: {
  155. PubIndeptTag,
  156. SingleSelect
  157. }
  158. }
  159. </script>
  160. <style lang="less">
  161. @import "../../less/common.less";
  162. .NoiseTemplateWrapper {
  163. .groupTitle {
  164. background-color: #fff;
  165. height: 40px;
  166. line-height: 40px;
  167. padding-left: 20px;
  168. }
  169. .main {
  170. background-color: #fff;
  171. margin: 0 20px 20px;
  172. padding: 20px;
  173. border-top: 1px solid @icssBorder;
  174. box-sizing: border-box;
  175. font-size: 14px;
  176. color: #606266;
  177. .title {
  178. margin-bottom: 20px;
  179. i {
  180. color: #f56c6c;
  181. }
  182. }
  183. }
  184. .btn {
  185. text-align: right;
  186. }
  187. .order {
  188. margin-bottom: 20px;
  189. .el-input__inner {
  190. line-height: 30px;
  191. height: 30px;
  192. }
  193. }
  194. }
  195. </style>