AddIndeptLabel.vue 10 KB

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