index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="10" class="mb8">
  4. <el-col :span="12">
  5. <el-card>
  6. <div ref="bmLeft" style="height: 300px;"></div>
  7. </el-card>
  8. </el-col>
  9. <el-col :span="12" style="text-align: right">
  10. <el-card>
  11. <div ref="bmRight" style="height: 300px;"></div>
  12. </el-card>
  13. </el-col>
  14. </el-row>
  15. <el-row :gutter="10" class="mb8">
  16. <el-col :span="18">
  17. <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="0">
  18. <el-form-item label="" prop="modelName" style="margin-right:10px">
  19. <el-input
  20. v-model="queryParams.modelName"
  21. placeholder="请输入模型名称"
  22. clearable
  23. @keyup.enter="handleQuery"
  24. />
  25. </el-form-item>
  26. <el-form-item>
  27. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  28. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  29. </el-form-item>
  30. </el-form>
  31. </el-col>
  32. <el-col :span="6" style="text-align: right">
  33. <el-button
  34. type="primary"
  35. plain
  36. icon="Plus"
  37. @click="handleAdd"
  38. v-hasPermi="['hl:bm:add']"
  39. >新增
  40. </el-button>
  41. </el-col>
  42. </el-row>
  43. <el-table v-loading="loading" :data="bmList" border>
  44. <!-- <el-table-column label="模型ID" align="center" prop="modelId" width="80" :hidden="hidden"/>-->
  45. <el-table-column label="模型名称" align="left" prop="modelName"/>
  46. <!-- <el-table-column label="昨日健康度" align="center" prop="yesterdayScore" width="180"/>-->
  47. <!-- <el-table-column label="最近一次健康度得分" align="center" prop="lastScore" width="180"/>-->
  48. <!-- <el-table-column label="更新时间" align="left" prop="updateTime" width="180">-->
  49. <!-- <template #default="scope">-->
  50. <!-- <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d} {h}:{mi}:{s}') }}</span>-->
  51. <!-- </template>-->
  52. <!-- </el-table-column>-->
  53. <el-table-column label="操作" width="480" class-name="small-padding fixed-width" align="left">
  54. <template #default="scope">
  55. <el-button link type="primary" icon="Position" @click="handleHealthSet(scope.row,'health')">健康度配置
  56. </el-button>
  57. <el-button link type="primary" icon="Calendar" @click="handleHealthSet(scope.row,'history')">历史健康度
  58. </el-button>
  59. <el-button link type="primary" icon="Clock" @click="handleHealthSet(scope.row,'day')">日健康度</el-button>
  60. <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['hl:bm:edit']">修改
  61. </el-button>
  62. <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['hl:bm:remove']">
  63. 删除
  64. </el-button>
  65. </template>
  66. </el-table-column>
  67. </el-table>
  68. <pagination
  69. v-show="total>0"
  70. :total="total"
  71. v-model:page="queryParams.pageNum"
  72. v-model:limit="queryParams.pageSize"
  73. @pagination="getList"
  74. />
  75. <!-- 添加或修改业务模型对话框 -->
  76. <el-dialog :title="title" v-model="open" :width="dialogType ==='health'?'1200px':'800px'" append-to-body
  77. :style="dialogType ==='health'?'margin-top:2px!important;':''">
  78. <add-bm-info ref="bmRef" @cancel="open = false" @success="getList" v-if="dialogType==='add'"/>
  79. <component :is="activeComponent[currentActive]" v-else-if="dialogType!=='add' && open" :modelId="modelId"
  80. :dialogType="dialogType"/>
  81. </el-dialog>
  82. </div>
  83. </template>
  84. <script setup name="Bm">
  85. import {addBm, delBm, listBm, updateBm} from "@/api/hl/bm";
  86. import {history} from "@/api/hl/hlScore";
  87. import {history as dayHistory} from "@/api/hl/hlDay";
  88. import addBmInfo from "./component/addBm.vue"
  89. import healthSetting from "./component/healthSetting.vue"
  90. import historyHealth from "./component/historyHealth.vue"
  91. import * as echarts from 'echarts'
  92. const {proxy} = getCurrentInstance();
  93. const bmList = ref([]);
  94. const open = ref(false);
  95. const loading = ref(true);
  96. const showSearch = ref(true);
  97. const ids = ref([]);
  98. const single = ref(true);
  99. const multiple = ref(true);
  100. const total = ref(0);
  101. const title = ref("");
  102. const dialogType = ref("add")
  103. const modelId = ref(0)
  104. const activeComponent = [healthSetting, historyHealth]
  105. const currentActive = ref(0)
  106. const bmLeft = ref(null)
  107. const bmRight = ref(null)
  108. const data = reactive({
  109. form: {},
  110. queryParams: {
  111. pageNum: 1,
  112. pageSize: 10,
  113. modelCode: null,
  114. modelName: null,
  115. modelScore: null,
  116. modelType: null,
  117. createBy: null,
  118. createTime: null,
  119. updateBy: null,
  120. updateTime: null,
  121. remark: null
  122. },
  123. rules: {}
  124. });
  125. const {queryParams, form, rules} = toRefs(data);
  126. function handleHealthSet(row, type) {
  127. modelId.value = row.modelId
  128. currentActive.value = type === "health" ? 0 : 1
  129. dialogType.value = type
  130. open.value = true
  131. title.value = type === "health" ? "健康度配置" : (row.modelName + ((type === "day" ? "日" : "历史") + "健康度"))
  132. }
  133. function initChatLeft(res, tag) {
  134. let obj = bmLeft;
  135. let title = "24小时健康度趋势"
  136. if (tag == 'right') {
  137. obj = bmRight;
  138. title = "最近7天健康度趋势"
  139. }
  140. const myChart = echarts.init(obj.value);
  141. let ss = [];
  142. for (let i = 0; i < res.length; i++) {
  143. let xx = {
  144. name: res[i].modelName,
  145. type: 'line',
  146. data: res[i].scores,
  147. symbolSize: 1,
  148. symbol: 'circle',
  149. smooth: true,
  150. showSymbol: false
  151. }
  152. ss.push(xx);
  153. }
  154. let x_data = res[0].xdata;
  155. let option = {
  156. backgroundColor: '#FFFFFF',
  157. title: {
  158. show: true,
  159. text: title,
  160. textStyle: {
  161. fontFamily: 'PingFangSC-Regular, PingFang SC',
  162. fontSize: 16,
  163. fontWeight: 600,
  164. color: '#848E98'
  165. },
  166. left: 'left',
  167. top: '3%'
  168. },
  169. legend: {
  170. icon: 'rect',
  171. top: '3%',
  172. right: '10%',
  173. itemWidth: 10,
  174. itemHeight: 10,
  175. itemGap: 20,
  176. textStyle: {
  177. fontFamily: 'PingFangSC-Regular, PingFang SC',
  178. color: '#848E98'
  179. }
  180. },
  181. tooltip: {
  182. trigger: 'axis',
  183. axisPointer: {
  184. label: {
  185. show: true,
  186. backgroundColor: '#fff',
  187. color: '#556677',
  188. borderColor: 'rgba(0,0,0,0)',
  189. shadowColor: 'rgba(0,0,0,0)',
  190. shadowOffsetY: 0
  191. },
  192. lineStyle: {
  193. width: 0
  194. }
  195. },
  196. backgroundColor: '#fff',
  197. textStyle: {
  198. color: '#5c6c7c'
  199. },
  200. padding: [10, 10],
  201. extraCssText: 'box-shadow: 1px 0 2px 0 rgba(163,163,163,0.5)'
  202. },
  203. grid: {
  204. top: '18%'
  205. },
  206. xAxis: [{
  207. type: 'category',
  208. data: x_data,
  209. axisLine: {
  210. show: false,
  211. lineStyle: {
  212. color: '#000000'
  213. }
  214. },
  215. axisTick: {
  216. show: false
  217. },
  218. axisLabel: {
  219. interval: 0,
  220. rotate: 0,
  221. textStyle: {
  222. color: '#B7C3CE'
  223. },
  224. // 默认x轴字体大小
  225. fontSize: 12,
  226. // margin:文字到x轴的距离
  227. margin: 5
  228. }
  229. }],
  230. yAxis: [{
  231. type: 'value',
  232. axisTick: {
  233. show: false
  234. },
  235. axisLine: {
  236. show: false,
  237. },
  238. axisLabel: {
  239. fontSize: 12,
  240. textStyle: {
  241. color: '#B7C3CE'
  242. }
  243. },
  244. splitLine: {
  245. show: true,
  246. lineStyle: {
  247. type: "dashed"
  248. }
  249. }
  250. }],
  251. series: ss
  252. };
  253. myChart.setOption(option)
  254. }
  255. /** 查询业务模型列表 */
  256. function getList() {
  257. history().then(response => {
  258. proxy.$nextTick(() => {
  259. initChatLeft(response, 'left');
  260. })
  261. });
  262. dayHistory().then(response => {
  263. proxy.$nextTick(() => {
  264. initChatLeft(response, 'right');
  265. })
  266. });
  267. loading.value = true;
  268. listBm(queryParams.value).then(response => {
  269. bmList.value = response.rows;
  270. total.value = response.total;
  271. loading.value = false;
  272. });
  273. }
  274. // 取消按钮
  275. function cancel() {
  276. open.value = false;
  277. reset();
  278. }
  279. // 表单重置
  280. function reset() {
  281. form.value = {
  282. modelId: null,
  283. modelCode: null,
  284. modelName: null,
  285. modelScore: null,
  286. modelType: null,
  287. createBy: null,
  288. createTime: null,
  289. updateBy: null,
  290. updateTime: null,
  291. remark: null
  292. };
  293. // proxy.resetForm("bmRef");
  294. }
  295. /** 搜索按钮操作 */
  296. function handleQuery() {
  297. queryParams.value.pageNum = 1;
  298. getList();
  299. }
  300. /** 重置按钮操作 */
  301. function resetQuery() {
  302. proxy.resetForm("queryRef");
  303. handleQuery();
  304. }
  305. // 多选框选中数据
  306. function handleSelectionChange(selection) {
  307. ids.value = selection.map(item => item.modelId);
  308. single.value = selection.length != 1;
  309. multiple.value = !selection.length;
  310. }
  311. /** 新增按钮操作 */
  312. function handleAdd() {
  313. reset();
  314. dialogType.value = "add"
  315. open.value = true;
  316. title.value = "添加业务模型";
  317. proxy.$nextTick(() => {
  318. proxy.$refs["bmRef"].editRow(null)
  319. })
  320. }
  321. /** 修改按钮操作 */
  322. function handleUpdate(row) {
  323. dialogType.value = "add"
  324. open.value = true;
  325. title.value = "修改业务模型";
  326. proxy.$nextTick(() => {
  327. proxy.$refs["bmRef"].editRow(row)
  328. })
  329. }
  330. /** 提交按钮 */
  331. function submitForm() {
  332. proxy.$refs["bmRef"].validate(valid => {
  333. if (valid) {
  334. if (form.value.modelId != null) {
  335. updateBm(form.value).then(response => {
  336. proxy.$modal.msgSuccess("修改成功");
  337. open.value = false;
  338. getList();
  339. });
  340. } else {
  341. addBm(form.value).then(response => {
  342. proxy.$modal.msgSuccess("新增成功");
  343. open.value = false;
  344. getList();
  345. });
  346. }
  347. }
  348. });
  349. }
  350. /** 删除按钮操作 */
  351. function handleDelete(row) {
  352. const _modelIds = row.modelId || ids.value;
  353. proxy.$modal.confirm('是否确认删除业务模型编号为"' + _modelIds + '"的数据项?').then(function () {
  354. return delBm(_modelIds);
  355. }).then(() => {
  356. getList();
  357. proxy.$modal.msgSuccess("删除成功");
  358. }).catch(() => {
  359. });
  360. }
  361. /** 导出按钮操作 */
  362. function handleExport() {
  363. proxy.download('hl/bm/export', {
  364. ...queryParams.value
  365. }, `bm_${new Date().getTime()}.xlsx`)
  366. }
  367. getList();
  368. </script>