AddIndeptLabel.vue 9.0 KB

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