healthSetting.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <el-button type="primary" plain @click="handleAddClass">导入对象类型</el-button>
  3. <el-table :data="bmConfigData" border style="width: 100%">
  4. <el-table-column label="对像类型" width="120">
  5. <template #default="scope">
  6. <dict-tag :options="biz_type" :value="scope.row.objType"/>
  7. </template>
  8. </el-table-column>
  9. <el-table-column label="业务对象" >
  10. <template #default="scope">
  11. <el-button type="primary" link @click="selectObj(scope.row)">
  12. <span v-for="(item,index) in scope.row.hlObjList" :key="`${scope.$index}_${item.hlObjId}`">
  13. {{item.objName}}<span v-if="index != scope.row.hlObjList.length-1">,</span>
  14. </span>
  15. </el-button>
  16. </template>
  17. </el-table-column>
  18. <el-table-column label="分值" width="120" align="center">
  19. <template #default="scope">
  20. <el-input v-model="scope.row.hlScore" @blur="changeHlRow(scope.row)"/>
  21. </template>
  22. </el-table-column>
  23. <el-table-column label="指标细项" width="155" align="center">
  24. <template #default="scope">
  25. <el-select v-model="scope.row.scoreType" placeholder="请选择细项分" clearable @change="changeHlRow(scope.row)">
  26. <el-option
  27. v-for="dict in metrics_small_type"
  28. :key="dict.value"
  29. :label="dict.label"
  30. :value="dict.value"
  31. />
  32. </el-select>
  33. </template>
  34. </el-table-column>
  35. <el-table-column label="操作" width="210">
  36. <template #default="scope">
  37. <el-button type="primary" link icon="Position" @click="hcClassManage(scope.row)">健康指标管理</el-button>
  38. <el-button type="primary" link icon="delete" @click="delBc(scope.row)">删除</el-button>
  39. </template>
  40. </el-table-column>
  41. </el-table>
  42. <el-dialog title="健康指标管理" v-model="visibleHcMange" width="800">
  43. <hm-list :hmRow="hmRow" v-if="visibleHcMange"/>
  44. </el-dialog>
  45. <el-dialog title="选择对象" v-model="visible" >
  46. <el-button type="primary" plain @click="handleAddHl">选择对象</el-button>
  47. <el-table :data="hlData" border style="width: 100%;margin-top:10px;">
  48. <el-table-column label="对象名称" prop="objName"/>
  49. <el-table-column label="操作" width="120" align="center">
  50. <template #default="scope">
  51. <el-button type="primary" link icon="delete" @click="handleHlDelete(scope.row)">删除</el-button>
  52. </template>
  53. </el-table-column>
  54. </el-table>
  55. </el-dialog>
  56. <el-dialog title="添加对象" v-model="visibleHl">
  57. <el-table :data="selectHlData" border style="width: 100%;margin-top:10px;" @selection-change="handleSelectionChange">
  58. <el-table-column type="selection" width="55" align="center" />
  59. <el-table-column label="对象名称">
  60. <template #default="scope">
  61. {{scope.row.bizObj.objName}}
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. <div class="btn-row">
  66. <el-button type="primary" @click="handleHlAdd">添加</el-button>
  67. <el-button @click="visibleHl=false">取消</el-button>
  68. </div>
  69. </el-dialog>
  70. </template>
  71. <script setup lang="ts">
  72. import {getBmConfig,impClass} from "@/api/hl/bm"
  73. import {hlClassList,deleteHlClass,selectHlList,addHoList} from "@/api/hl/ho"
  74. import {updateHc,delHc} from "@/api/hl/hc"
  75. import {onMounted} from "vue";
  76. import hmList from "./widget/hmList.vue"
  77. const {proxy} = getCurrentInstance()
  78. const props = defineProps(['modelId'])
  79. const {biz_type,metrics_small_type} = proxy.useDict('biz_type','metrics_small_type');
  80. const bmConfigData = ref([])
  81. const hlData = ref([])
  82. const selectHlData = ref([])
  83. const visible = ref(false)
  84. const hlId = ref(null)
  85. const hlIds = ref([])
  86. const visibleHl = ref(false)
  87. const visibleHcMange = ref(false)
  88. const hmRow = ref({})
  89. onMounted(()=>{
  90. bmConfigList(props.modelId)
  91. })
  92. async function delBc(row){
  93. await delHc(row.hlClassId)
  94. await bmConfigList(props.modelId)
  95. }
  96. function hcClassManage(row){
  97. visibleHcMange.value = true
  98. hmRow.value=row;
  99. }
  100. function changeHlRow(row){
  101. let count = 0
  102. bmConfigData.value.forEach(p=>{
  103. count += Number(p.hlScore)
  104. })
  105. if(count>100){
  106. return proxy.$message.error("健康分值不能超过100")
  107. }
  108. updateHc(row)
  109. }
  110. function handleSelectionChange(selection){
  111. hlIds.value = selection.map(item => item.objId);
  112. }
  113. async function bmConfigList(modelId){
  114. const res = await getBmConfig(modelId)
  115. bmConfigData.value = res.data
  116. }
  117. async function selectObj({hlClassId}){
  118. const res = await hlClassList(hlClassId)
  119. hlId.value = hlClassId
  120. hlData.value = res.data
  121. visible.value = true
  122. }
  123. async function handleAddHl(){
  124. const res = await selectHlList(hlId.value)
  125. visibleHl.value = true
  126. selectHlData.value = res.data
  127. }
  128. async function handleAddClass(){
  129. const res = await impClass(props.modelId)
  130. await bmConfigList(props.modelId)
  131. }
  132. async function handleHlDelete({hlObjId,hlClassId}){
  133. await deleteHlClass(hlObjId)
  134. await selectObj({hlClassId})
  135. await bmConfigList(props.modelId)
  136. }
  137. async function handleHlAdd(){
  138. if(!hlIds.value.length) return proxy.$modal.msgError("请选择对象")
  139. await addHoList(hlId.value,{objIds:[...hlIds.value].join(",")})
  140. await handleAddHl()
  141. await selectObj({hlClassId:hlId.value})
  142. await bmConfigList(props.modelId)
  143. visibleHl.value = false
  144. hlIds.value = []
  145. }
  146. </script>
  147. <style scoped lang="scss">
  148. .btn-row{
  149. margin-top: 20px;
  150. display: flex;
  151. justify-content: center;
  152. }
  153. </style>