AddIndeptLabel.vue 11 KB

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