AddIndeptLabel.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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 || 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)
  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. for (let i = 0; i < this.options.length; i++) {
  97. if(this.options[i].name.trim() != '') {
  98. isNull = false
  99. options2.push(this.options[i])
  100. }
  101. }
  102. this.options = options2;
  103. if(this.itemsTypes.includes(+this.dataPub.region2)&&isNull) {
  104. this.$message({
  105. message: '至少填一个选项',
  106. type: 'warning'
  107. });
  108. return;
  109. }
  110. if(this.dataPub.region8 >= this.dataPub.region9) {
  111. this.$message({
  112. message: '最小年龄不能大于或等于最大年龄',
  113. type: 'warning'
  114. });
  115. return;
  116. }
  117. const {isEdit,data} = this.$route.params;
  118. let param = {
  119. "questionWrapper": {
  120. "controlType": this.dataPub.region2, //控件类型(0:默认值 1:下拉单选 2:下拉多选 6:文本框 7:数字键盘文本框 99:联合推送)
  121. "id": isEdit?data.id:'', //新增id置空
  122. "type": this.dataPub.region1, //标签归属
  123. "tagType": 1, //标签类型
  124. "tagName": this.dataPub.region3, //系统名称
  125. "name": this.dataPub.region4, //界面名称
  126. "joint": this.dataPub.region5, //标签间的连接符
  127. "subType": this.dataPub.region6, //0:可以,1:不可以(当项目检索)
  128. "sexType": this.dataPub.region7, //1:男,2:女,3:通用
  129. "ageBegin": this.dataPub.region8, //最小年龄
  130. "ageEnd": this.dataPub.region9, //最大年龄
  131. "textGenerate": this.form.currentOrder, //成文顺序 默认0
  132. "copyType": this.dataPub.region2 == 6 ? this.dataPub.region10 : (this.dataPub.region2 == 3 ? this.dataPub.region11 : ''), //是否复制
  133. "showAdd": 0, //是否显示加号血压
  134. "showInfo": 0,
  135. "labelPrefix":this.dataPub.prefix, //前缀
  136. "labelSuffix":this.dataPub.suffix, //后缀
  137. "minValue": this.dataPub.minNormalVal, //化验最小正常值
  138. "maxValue": this.dataPub.maxNormalVal, //化验最大正常值
  139. "questionDetails": this.options,
  140. "questionMappings": [], //映射关系,
  141. "formulaCode": isEdit?data.formulaCode : ''
  142. }
  143. };
  144. this.showSaveDialog(param);
  145. },
  146. showSaveDialog(param) {
  147. /*this.showConfirmDialog('是否保存该标签?', () => {
  148. api.saveOrUpdate(param).then((res) => {
  149. if (res.data.code === '0') {
  150. this.warning(res.data.msg || '保存成功', 'success');
  151. this.$router.push("/admin/LT-YXSJWH-DLLXBQWH");
  152. } else {
  153. this.warning(res.data.msg)
  154. }
  155. }).catch((err) => {
  156. this.warning(err);
  157. })
  158. });*/
  159. const h = this.$createElement;
  160. this.$msgbox({
  161. title:'提示',
  162. message:h('div',{style:'padding-bottom:10px'},[
  163. h('p',{style:'font-size:15px;margin-bottom:10px'},'是否保存该标签?'),
  164. h('span',{style:'color:red;font-size:12px'},'标签系统名称已经改变,请去别名维护中修改相关信息'),
  165. ]),
  166. showCancelButton: true,
  167. distinguishCancelAndClose:true,
  168. confirmButtonText: '确认并前往别名维护',
  169. cancelButtonText:'确认',
  170. // type: 'warning',
  171. cancelButtonClass:'toast-cancel'
  172. }).then(()=>{
  173. api.saveOrUpdate(param).then((res) => {
  174. if (res.data.code === '0') {
  175. this.warning(res.data.msg || '保存成功', 'success');
  176. this.$router.push({
  177. name:'AddSimilarName',
  178. params: {id:param.questionWrapper.id,name:param.questionWrapper.tagName}
  179. })
  180. } else {
  181. this.warning(res.data.msg)
  182. }
  183. }).catch((err) => {
  184. this.warning(err);
  185. })
  186. }).catch((action)=>{
  187. // action :cancel--取消,close--关闭
  188. if(action=='cancel'){
  189. api.saveOrUpdate(param).then((res) => {
  190. if (res.data.code === '0') {
  191. this.warning(res.data.msg || '保存成功', 'success');
  192. this.$router.push("/admin/LT-YXSJWH-DLLXBQWH");
  193. } else {
  194. this.warning(res.data.msg)
  195. }
  196. }).catch((err) => {
  197. this.warning(err);
  198. })
  199. }
  200. })
  201. },
  202. showConfirmDialog(msg, resolve) {
  203. this.$alert(msg, '提示', {
  204. confirmButtonText: '确定',
  205. type: 'warning'
  206. }).then(() => {
  207. resolve();
  208. }).catch(() => {});
  209. },
  210. warning(msg, type) {
  211. this.$message({
  212. showClose: true,
  213. message: msg,
  214. type: type || 'warning'
  215. })
  216. },
  217. },
  218. components: {
  219. PubIndeptTag,
  220. SingleSelect
  221. }
  222. }
  223. </script>
  224. <style lang="less">
  225. @import "../../less/common.less";
  226. .NoiseTemplateWrapper {
  227. .groupTitle {
  228. background-color: #fff;
  229. height: 40px;
  230. line-height: 40px;
  231. padding-left: 20px;
  232. }
  233. .main {
  234. background-color: #fff;
  235. margin: 0 20px 20px;
  236. padding: 20px;
  237. border-top: 1px solid @icssBorder;
  238. box-sizing: border-box;
  239. font-size: 14px;
  240. color: #606266;
  241. .title {
  242. margin-bottom: 20px;
  243. i {
  244. color: #f56c6c;
  245. }
  246. }
  247. }
  248. .btn {
  249. text-align: right;
  250. }
  251. .order {
  252. margin-bottom: 20px;
  253. .el-input__inner {
  254. line-height: 30px;
  255. height: 30px;
  256. }
  257. }
  258. }
  259. .toast-cancel{
  260. color: #22ccc8 !important;
  261. // background: #22ccc8;
  262. }
  263. </style>