123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393 |
- <template>
- <div class="app-container">
- <el-row :gutter="10" class="mb8">
- <el-col :span="12">
- <el-card>
- <div ref="bmLeft" style="height: 300px;"></div>
- </el-card>
- </el-col>
- <el-col :span="12" style="text-align: right">
- <el-card>
- <div ref="bmRight" style="height: 300px;"></div>
- </el-card>
- </el-col>
- </el-row>
- <el-row :gutter="10" class="mb8">
- <el-col :span="18">
- <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="0">
- <el-form-item label="" prop="modelName" style="margin-right:10px">
- <el-input
- v-model="queryParams.modelName"
- placeholder="请输入模型名称"
- clearable
- @keyup.enter="handleQuery"
- />
- </el-form-item>
- <el-form-item>
- <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
- <el-button icon="Refresh" @click="resetQuery">重置</el-button>
- </el-form-item>
- </el-form>
- </el-col>
- <el-col :span="6" style="text-align: right">
- <el-button
- type="primary"
- plain
- icon="Plus"
- @click="handleAdd"
- v-hasPermi="['hl:bm:add']"
- >新增
- </el-button>
- </el-col>
- </el-row>
- <el-table v-loading="loading" :data="bmList" border>
- <!-- <el-table-column label="模型ID" align="center" prop="modelId" width="80" :hidden="hidden"/>-->
- <el-table-column label="模型名称" align="left" prop="modelName"/>
- <!-- <el-table-column label="昨日健康度" align="center" prop="yesterdayScore" width="180"/>-->
- <!-- <el-table-column label="最近一次健康度得分" align="center" prop="lastScore" width="180"/>-->
- <!-- <el-table-column label="更新时间" align="left" prop="updateTime" width="180">-->
- <!-- <template #default="scope">-->
- <!-- <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d} {h}:{mi}:{s}') }}</span>-->
- <!-- </template>-->
- <!-- </el-table-column>-->
- <el-table-column label="操作" width="480" class-name="small-padding fixed-width" align="left">
- <template #default="scope">
- <el-button link type="primary" icon="Position" @click="handleHealthSet(scope.row,'health')">健康度配置
- </el-button>
- <el-button link type="primary" icon="Calendar" @click="handleHealthSet(scope.row,'history')">历史健康度
- </el-button>
- <el-button link type="primary" icon="Clock" @click="handleHealthSet(scope.row,'day')">日健康度</el-button>
- <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['hl:bm:edit']">修改
- </el-button>
- <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['hl:bm:remove']">
- 删除
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- <pagination
- v-show="total>0"
- :total="total"
- v-model:page="queryParams.pageNum"
- v-model:limit="queryParams.pageSize"
- @pagination="getList"
- />
- <!-- 添加或修改业务模型对话框 -->
- <el-dialog :title="title" v-model="open" :width="dialogType ==='health'?'1200px':'800px'" append-to-body
- :style="dialogType ==='health'?'margin-top:2px!important;':''">
- <add-bm-info ref="bmRef" @cancel="open = false" @success="getList" v-if="dialogType==='add'"/>
- <component :is="activeComponent[currentActive]" v-else-if="dialogType!=='add' && open" :modelId="modelId"
- :dialogType="dialogType"/>
- </el-dialog>
- </div>
- </template>
- <script setup name="Bm">
- import {addBm, delBm, listBm, updateBm} from "@/api/hl/bm";
- import {history} from "@/api/hl/hlScore";
- import {history as dayHistory} from "@/api/hl/hlDay";
- import addBmInfo from "./component/addBm.vue"
- import healthSetting from "./component/healthSetting.vue"
- import historyHealth from "./component/historyHealth.vue"
- import * as echarts from 'echarts'
- const {proxy} = getCurrentInstance();
- const bmList = ref([]);
- const open = ref(false);
- const loading = ref(true);
- const showSearch = ref(true);
- const ids = ref([]);
- const single = ref(true);
- const multiple = ref(true);
- const total = ref(0);
- const title = ref("");
- const dialogType = ref("add")
- const modelId = ref(0)
- const activeComponent = [healthSetting, historyHealth]
- const currentActive = ref(0)
- const bmLeft = ref(null)
- const bmRight = ref(null)
- const data = reactive({
- form: {},
- queryParams: {
- pageNum: 1,
- pageSize: 10,
- modelCode: null,
- modelName: null,
- modelScore: null,
- modelType: null,
- createBy: null,
- createTime: null,
- updateBy: null,
- updateTime: null,
- remark: null
- },
- rules: {}
- });
- const {queryParams, form, rules} = toRefs(data);
- function handleHealthSet(row, type) {
- modelId.value = row.modelId
- currentActive.value = type === "health" ? 0 : 1
- dialogType.value = type
- open.value = true
- title.value = type === "health" ? "健康度配置" : (row.modelName + ((type === "day" ? "日" : "历史") + "健康度"))
- }
- function initChatLeft(res, tag) {
- let obj = bmLeft;
- let title = "24小时健康度趋势"
- if (tag == 'right') {
- obj = bmRight;
- title = "最近7天健康度趋势"
- }
- const myChart = echarts.init(obj.value);
- let ss = [];
- for (let i = 0; i < res.length; i++) {
- let xx = {
- name: res[i].modelName,
- type: 'line',
- data: res[i].scores,
- symbolSize: 1,
- symbol: 'circle',
- smooth: true,
- showSymbol: false
- }
- ss.push(xx);
- }
- let x_data = res[0].xdata;
- let option = {
- backgroundColor: '#FFFFFF',
- title: {
- show: true,
- text: title,
- textStyle: {
- fontFamily: 'PingFangSC-Regular, PingFang SC',
- fontSize: 16,
- fontWeight: 600,
- color: '#848E98'
- },
- left: 'left',
- top: '3%'
- },
- legend: {
- icon: 'rect',
- top: '3%',
- right: '10%',
- itemWidth: 10,
- itemHeight: 10,
- itemGap: 20,
- textStyle: {
- fontFamily: 'PingFangSC-Regular, PingFang SC',
- color: '#848E98'
- }
- },
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- label: {
- show: true,
- backgroundColor: '#fff',
- color: '#556677',
- borderColor: 'rgba(0,0,0,0)',
- shadowColor: 'rgba(0,0,0,0)',
- shadowOffsetY: 0
- },
- lineStyle: {
- width: 0
- }
- },
- backgroundColor: '#fff',
- textStyle: {
- color: '#5c6c7c'
- },
- padding: [10, 10],
- extraCssText: 'box-shadow: 1px 0 2px 0 rgba(163,163,163,0.5)'
- },
- grid: {
- top: '18%'
- },
- xAxis: [{
- type: 'category',
- data: x_data,
- axisLine: {
- show: false,
- lineStyle: {
- color: '#000000'
- }
- },
- axisTick: {
- show: false
- },
- axisLabel: {
- interval: 0,
- rotate: 0,
- textStyle: {
- color: '#B7C3CE'
- },
- // 默认x轴字体大小
- fontSize: 12,
- // margin:文字到x轴的距离
- margin: 5
- }
- }],
- yAxis: [{
- type: 'value',
- axisTick: {
- show: false
- },
- axisLine: {
- show: false,
- },
- axisLabel: {
- fontSize: 12,
- textStyle: {
- color: '#B7C3CE'
- }
- },
- splitLine: {
- show: true,
- lineStyle: {
- type: "dashed"
- }
- }
- }],
- series: ss
- };
- myChart.setOption(option)
- }
- /** 查询业务模型列表 */
- function getList() {
- history().then(response => {
- proxy.$nextTick(() => {
- initChatLeft(response, 'left');
- })
- });
- dayHistory().then(response => {
- proxy.$nextTick(() => {
- initChatLeft(response, 'right');
- })
- });
- loading.value = true;
- listBm(queryParams.value).then(response => {
- bmList.value = response.rows;
- total.value = response.total;
- loading.value = false;
- });
- }
- // 取消按钮
- function cancel() {
- open.value = false;
- reset();
- }
- // 表单重置
- function reset() {
- form.value = {
- modelId: null,
- modelCode: null,
- modelName: null,
- modelScore: null,
- modelType: null,
- createBy: null,
- createTime: null,
- updateBy: null,
- updateTime: null,
- remark: null
- };
- // proxy.resetForm("bmRef");
- }
- /** 搜索按钮操作 */
- function handleQuery() {
- queryParams.value.pageNum = 1;
- getList();
- }
- /** 重置按钮操作 */
- function resetQuery() {
- proxy.resetForm("queryRef");
- handleQuery();
- }
- // 多选框选中数据
- function handleSelectionChange(selection) {
- ids.value = selection.map(item => item.modelId);
- single.value = selection.length != 1;
- multiple.value = !selection.length;
- }
- /** 新增按钮操作 */
- function handleAdd() {
- reset();
- dialogType.value = "add"
- open.value = true;
- title.value = "添加业务模型";
- proxy.$nextTick(() => {
- proxy.$refs["bmRef"].editRow(null)
- })
- }
- /** 修改按钮操作 */
- function handleUpdate(row) {
- dialogType.value = "add"
- open.value = true;
- title.value = "修改业务模型";
- proxy.$nextTick(() => {
- proxy.$refs["bmRef"].editRow(row)
- })
- }
- /** 提交按钮 */
- function submitForm() {
- proxy.$refs["bmRef"].validate(valid => {
- if (valid) {
- if (form.value.modelId != null) {
- updateBm(form.value).then(response => {
- proxy.$modal.msgSuccess("修改成功");
- open.value = false;
- getList();
- });
- } else {
- addBm(form.value).then(response => {
- proxy.$modal.msgSuccess("新增成功");
- open.value = false;
- getList();
- });
- }
- }
- });
- }
- /** 删除按钮操作 */
- function handleDelete(row) {
- const _modelIds = row.modelId || ids.value;
- proxy.$modal.confirm('是否确认删除业务模型编号为"' + _modelIds + '"的数据项?').then(function () {
- return delBm(_modelIds);
- }).then(() => {
- getList();
- proxy.$modal.msgSuccess("删除成功");
- }).catch(() => {
- });
- }
- /** 导出按钮操作 */
- function handleExport() {
- proxy.download('hl/bm/export', {
- ...queryParams.value
- }, `bm_${new Date().getTime()}.xlsx`)
- }
- getList();
- </script>
|