Procházet zdrojové kódy

Merge branch '王立生' of sckj/mz-cloud into master

sckj před 2 roky
rodič
revize
475cdece41

+ 1 - 1
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysDictTypeController.java

@@ -300,6 +300,6 @@ public class SysDictTypeController extends BaseController
             return rets;
         }
         else
-            return   AjaxResult.error("数据获取失败");
+            return   AjaxResult.error("数据获取失败"+ret.getMessage());
     }
 }

+ 90 - 34
ruoyi-ui/src/components/EchartsBox2/index.vue

@@ -19,12 +19,12 @@
             </div>
           </el-form-item>
           <el-form-item label="维度统计">
-            <el-select size="mini" v-model="formData.formSelect1" placeholder="请选择">
+            <el-select size="mini" v-model="formData.formSelect1" @change="change1(formData.formSelect1)" placeholder="请选择">
               <el-option v-for="item in options1" :key="item.value" :label="item.label" :value="item.value"> </el-option>
             </el-select>
           </el-form-item>
           <el-form-item label="问题名称">
-            <el-select size="mini" v-model="formData.formSelect2">
+            <el-select size="mini" v-model="formData.formSelect2" @change="change2(formData.formSelect2)" >
               <el-option v-for="item in options2" :key="item.value" :label="item.label" :value="item.value"> </el-option>
             </el-select>
           </el-form-item>
@@ -100,11 +100,11 @@ export default {
       // 多选框1配置项
       options1: [
         {
-          value: '选项1',
+          value: '01',
           label: '累计存在问题数量'
         },
         {
-          value: '选项2',
+          value: '02',
           label: '现在问题数量'
         }
       ],
@@ -129,6 +129,7 @@ export default {
       // 绑定选择日期范围
       yearChoose: '',
       radio: 'total',
+      filterc:'data1',
       newKeys: [],
       newTableList: [],
       newUnit: '',
@@ -154,12 +155,31 @@ export default {
   },
   methods: {
     // 改变多选框数据格式
+    change1(value)
+    {
+      this.$emit('changeData', value);
+
+    },
+    change2(value)
+    {
+      //alert(value);
+      this.filterc=value;
+
+
+      this.setTable(this.xStr, this.radio,this.filterc)
+
+      this.echartsInit(this.echartsId, this.type, this.newUnit, this.x, this.y, this.isX, this.isY)
+
+
+    },
     changeSelectSJGS() {
       let options = []
       let array = this.radioLabel.filter((item, index) => {
-        return index % 2 === 0
+        //return index % 2 === 0
+        return true
       })
       array.forEach((item, index) => {
+        if (index==0) this.formData.formSelect2 =item.prop;
         let obj = {
           label: '',
           value: ''
@@ -168,6 +188,7 @@ export default {
         obj.value = item.prop
         options.push(obj)
       })
+      this.formData.formSelect1 ='01';
       this.options2 = options
     },
     startTime() {},
@@ -218,27 +239,51 @@ export default {
     //   console.log(this.radioLabel)
     // },
     // 改变table中X轴的数据的数据格式 参数是 x轴对应的数据名字,y轴对应的数据名字
-    setTable(xAxis, yAxis) {
+    setTable(xAxis,yAxis1, yAxis2) {
       // x轴
       let arrX = []
       let arrY = []
+      let arrYa = []
+      let arrYb = []
       this.newTableList.forEach((item) => {
-        arrX.unshift(item[xAxis])
-        arrY.unshift(item[yAxis])
-      })
+        arrX.push(item[xAxis])
+        arrYa.push(item[yAxis1])
+        arrYb.push(item[yAxis2])
+      });
+
+
+      arrY[0]={};
+      arrY[0].label='已检查机构总数';
+      arrY[0].data=arrYa;
+
+      arrY[1]={};
+      if (this.formData.formSelect1=='01')
+        arrY[1].label=this.options1[0].label;
+      else
+        arrY[1].label=this.options1[1].label;
+      arrY[1].data=arrYb;
       this.x = arrX
       this.y = arrY
       if (this.isfftj === true) {
         this.x = this.newKeys.filter((item) => item.type === 'select').map((item) => item.label)
       }
     },
-    // 单选框改变事件
-    changRadio(item) {
-      this.setTable(this.xStr, item.prop)
-      this.echartsInit(this.echartsId, this.type, this.newUnit, this.x, this.y, this.isX, this.isY)
-    },
+
     // echarts 参数为:每个图表id,图表类型,单位,x轴数据,y轴数据,isX和isY是否是横向(value和category)
     echartsInit(id, type, unit, xAxis, yData, isX, isY) {
+      const labelOption = {
+        show: true,
+        position: 'top',
+        distance: 15,
+        align: 'left',
+        verticalAlign: 'middle',
+        rotate: 20,
+        // formatter: '{c}  {name|{a}}',
+        fontSize: 13,
+        rich: {
+          name: {}
+        }
+      };
       // 是否显示xy轴
       let isShow = true
       let yAxis = yData
@@ -248,19 +293,22 @@ export default {
           return { name: item.label, value: this.newTableList[0][item.prop] }
         })
       }
-      let obj = {
-        type: 'bar',
-        data: yAxis,
-        radius: ['35%', '65%'],
-        hoverAnimation: true,
-        avoidLabelOverlap: false
-      }
+
+
       var myChart = this.$echarts.init(document.getElementById(id))
       var option = {
         // color: ['#288DEF'],
-        title: {},
-        tooltip: {},
-        legend: {},
+        title: {
+        },
+        tooltip: {
+          trigger: 'axis',
+          axisPointer: {
+            type: 'shadow'
+          }
+        },
+        legend: {
+
+        },
         xAxis: {
           type: isX,
           show: isShow,
@@ -269,7 +317,7 @@ export default {
           axisLabel: {
             interval: 0,
             textStyle: {
-              color: '#000',
+              color: '#a14c4c',
               fontSize: '10',
               itemSize: ''
             }
@@ -289,17 +337,26 @@ export default {
         },
         series: [
           {
-            type,
-            data: yAxis,
+            type: "bar",
+            data: yAxis[0].data,
+            radius: ['35%', '65%'],
+            hoverAnimation: true,
+            avoidLabelOverlap: false,
+            name:yAxis[0].label,
+            label:labelOption
+          },
+          {
+            type: "bar",
+            data: yAxis[1].data,
             radius: ['35%', '65%'],
             hoverAnimation: true,
-            avoidLabelOverlap: false
+            avoidLabelOverlap: false,
+            name:yAxis[1].label,
+            label:labelOption
           }
         ]
       }
-      if (this.isTwoBar === 'yes') {
-        option.series.push(obj)
-      }
+
       myChart.setOption(option)
     }
   },
@@ -311,13 +368,12 @@ export default {
     },
     labelKeys(newVal) {
       this.newKeys = newVal
-      // this.setKeys()
       this.changeSelectSJGS()
-      console.log(this.radioLabel, 'radio')
+
     },
     tableList(newVal) {
       this.newTableList = newVal
-      this.setTable(this.xStr, 'total')
+      this.setTable(this.xStr, this.radio,this.filterc)
       this.echartsInit(this.echartsId, this.type, this.newUnit, this.x, this.y, this.isX, this.isY)
     }
   }

+ 59 - 42
ruoyi-ui/src/views/search/xxtj/xfaqjcqktj/xfaqwttj/index.vue

@@ -27,7 +27,7 @@
               <div class="ssqh">
                 <dept-tree :userId="user.userData.dept.parentId" @handleNodeClick="handleNodeClick"> </dept-tree>
               </div>
-              <Echarts-box2 isTwoBar="yes" v-if="index === 0" title="养老机构消防安全问题统计" :echartsId="'two' + dict.value" type="bar" xStr="year" :tableList="table1Data" :labelKeys="formData.keys"> </Echarts-box2>
+              <Echarts-box2 isTwoBar="yes" @changeData="changeDataA" v-if="index === 0" title="养老机构消防安全问题统计" :echartsId="'two' + dict.value" type="bar" xStr="year" :tableList="table1Data" :labelKeys="formData.keys"> </Echarts-box2>
               <Echarts-box isTwoBar="yes" v-if="index === 1" title="养老机构备案情况统计-月度" :echartsId="'w' + dict.value" :tableList="tableData" :labelKeys="formData.keys" type="bar" xStr="xzqh" :unit="formData.unit">
                 <el-date-picker @change="changDateYear" value-format="yyyy" v-model="formParams.ccnd" type="year" placeholder="选择年"> </el-date-picker>
               </Echarts-box>
@@ -161,61 +161,80 @@ export default {
       // 大tabs中第二页里绑定的时间
       ccnd: '',
       // 表格1中的数据源
-      table1Data: []
+      table1Data: [],
+      tabdata1:[],
+      tabdata2:[],
     }
   },
   methods: {
+    changeDataA(ret) {
+      this.table1Data=[];
+      if (ret=='02')
+        this.table1Data=this.tabdata2;
+      else
+        this.table1Data=this.tabdata1;
+    },
     table1Keys() {
+
       this.formData.keys.forEach((item, index) => {
-        let num = index - 1
-        if (index > 1) {
+        let num = index - 2
+        if (index > 2) {
           item.prop = 'data' + num
         }
       })
+
     },
-    // 表格1vales数据转换
     vales() {
       this.formData.vales.forEach((item) => {
         /*组成全是data对象 */
+
         let arr = Object.values(item)
-        let newArr = arr.splice(2)
+        let newArr = arr.splice(3)
+
         let OUArr = newArr.filter((item, index) => {
           return index % 2 === 0
         })
         let JIarr = newArr.filter((item, index) => {
           return index % 2 === 1
         })
-        // 基数偶数数组求和
-        let sumArr = JIarr.map((item, index) => {
-          let OUNumber = +OUArr[index]
-          let JINumber = +item
-          return (OUNumber += JINumber)
+
+        let newOBj1 = {}
+        OUArr.forEach((item, index) => {
+          let num = index + 1
+          let str = 'data' + num
+          newOBj1[str] = item
         })
-        // 由data组成的对象
-        let newOBj = {}
-        sumArr.forEach((item, index) => {
+        let newOBj2 = {}
+        JIarr.forEach((item, index) => {
           let num = index + 1
           let str = 'data' + num
-          newOBj[str] = item
+          newOBj2[str] = item
         })
-        /*取对象前2项操作 */
+        /*取对象前3项操作 */
         let keysArr = Object.keys(item)
-        let twoKeyArr = keysArr.splice(0, 2)
+        let twoKeyArr = keysArr.splice(0, 3)
+
         // 前两项的value
-        let twoValueArr = arr.splice(0, 2)
+        let twoValueArr = arr.splice(0, 3)
+
         let twoOBJ = {}
         twoKeyArr.forEach((item, index) => {
           twoOBJ[item] = twoValueArr[index]
         })
-        let finalObj = Object.assign(newOBj, twoOBJ)
-        this.table1Data.push(finalObj)
-        console.log(this.table1Data)
+
+        let obja=Object.assign(newOBj1, twoOBJ);
+        let objb=Object.assign(newOBj2, twoOBJ);
+        this.tabdata1.push(obja);
+        this.tabdata2.push(objb);
+        this.table1Data.push(obja);
+
       })
     },
     // 表变表格2数据格式
     keys() {
-      // this.tableData1.keys = this.formData.keys
-      console.log(this.formData, 'this.formData')
+
+     // console.log(JSON.stringify(this.formData), 'this.formData')
+
       let arr = []
       if (this.activeName1 === '1') {
         let unit = this.formData.unit.split(',')
@@ -226,27 +245,22 @@ export default {
             arr.push(item)
           } else if (item.type === 'select') {
             if (num % number === 0) {
-              //   arr.push({ ...item, data: unit })
-              item.data = []
-              item.data.push({ ...item, label: unit[num % number] })
-              arr.push(item)
+
+              var temitem=JSON.parse(JSON.stringify(item));
+              temitem.data = []
+              temitem.data.push({ ...item, label: unit[num % number] })
+              arr.push(temitem)
             } else {
-              // console.log(arr[arr.length - 1], 'arr[arr.length - 1]')
+
               arr[arr.length - 1].data.push({ ...item, label: unit[num % number] })
             }
-            // if (arr[index - 1] && arr[index - 1].data && arr[index - 1].data.length < unit.length) {
-            //   console.log(index, 'index11')
-            //   arr[index - 1].data.push({ ...item, label: unit[num % number] })
-            // } else {
-            //   item.data = []
-            //   item.data.push({ ...item, label: unit[num % number] })
-            //   arr.push(item)
-            // }
-            num++
+
+            num++;
+
           }
         })
         this.formData.keys = arr
-        console.log(arr, 'arr')
+      //  console.log(arr, 'arr')
       }
     },
     startTime() {},
@@ -303,6 +317,8 @@ export default {
       this.queryParams.para1 = this.activeName1
       this.getTableList()
       this.table1Data = []
+      this.tabdata1=[]
+      this.tabdata2=[]
     },
     // 子tabs栏切换事件
     handleTabsClick() {
@@ -310,8 +326,9 @@ export default {
       this.formData.keys = []
       this.formData.vales = []
       this.table1Data = []
+      this.tabdata1=[]
+      this.tabdata2=[]
       this.getTableList()
-      console.log(this.activeName2)
     },
     // 节点单击事件
     handleNodeClick(data) {
@@ -324,22 +341,22 @@ export default {
     },
     // 获取表格数据
     async getTableList() {
+
       let retdata = await getstatisticaldata(this.queryParams)
-      console.log(retdata)
       if (retdata.code == 200) {
         var data = this.$DBRetToObjA(retdata.data)
-        console.log(data)
         this.formData = data[0]
-        console.log(this.formData, 'formData')
         if (this.activeName2 === '2' || this.activeName2 === '1') {
           this.keys()
         }
         if (this.activeName1 === '1') {
+
           this.vales()
         }
         if (this.activeName1 === '1' && this.activeName2 === '1') {
           this.table1Keys()
         }
+
       }
     }
   },