瀏覽代碼

2021.06.22

East 3 年之前
父節點
當前提交
206af935f2

+ 1 - 0
src/router/index.js

@@ -68,6 +68,7 @@ router.beforeEach((to, from, next) => {
       params: http.adornParams()
     }).then(({data}) => {
       if (data && data.code === 0) {
+        console.log(data);
         fnAddDynamicMenuRoutes(data.menuList)
         router.options.isAddDynamicMenuRoutes = true
         sessionStorage.setItem('menuList', JSON.stringify(data.menuList || '[]'))

+ 3 - 0
src/views/common/login.vue

@@ -82,6 +82,9 @@
               if (data && data.code === 0) {
                 this.$cookie.set('token', data.token)
                 this.$cookie.set('farmId', data.farmId)
+                if (data.farmId) {
+                  this.$cookie.set('formFarmId', data.farmId)
+                }
                 localStorage.setItem('farmId', data.farmId)
                 this.$router.replace({ name: 'home' })
               } else {

+ 19 - 14
src/views/main-navbar.vue

@@ -72,7 +72,8 @@
     <el-dialog
       title="请选择牧场"
       :visible="dialogVisible"
-      width="30%">
+      width="30%"
+      :modal-append-to-body="false">
       <el-form 
         :model="dataForm" 
         :rules="dataRule" 
@@ -152,6 +153,17 @@
     methods: {
       // 获取牧场List
       getDataList() {
+        this.dialogVisible = true
+        this.farmId = this.$cookie.get('farmId') === 'null'? undefined: parseInt(this.$cookie.get('farmId'))
+        if (this.farmId || this.$cookie.get('formFarmId')) {
+          this.dialogVisible = false
+          // this.formFarmId = this.farmId
+          this.formFarmId = this.farmId || (parseInt(this.$cookie.get('formFarmId')) || '')
+          // this.$cookie.set('formFarmId', this.farmId)
+          // return
+        }
+        // this.formFarmId = this.$cookie.get('formFarmId') === null? undefined: parseInt(this.$cookie.get('formFarmId'))
+        // console.log(this.$cookie.get('formFarmId'));
         this.$http({
           url: this.$http.adornUrl("/management/farm/findAll"),
           method: "post",
@@ -174,19 +186,12 @@
             this.$message.error(data.msg)
           }
         })
-        this.dialogVisible = true
-        this.farmId = this.$cookie.get('farmId') === 'null'? undefined: parseInt(this.$cookie.get('farmId'))
-        if (this.farmId) {
-          this.dialogVisible = false
-          this.formFarmId = this.farmId
-          return
-        }
-        console.log(this.$cookie.get('formFarmId'));
-        this.formFarmId = this.$cookie.get('formFarmId') === null? undefined: parseInt(this.$cookie.get('formFarmId'))
-        if (this.formFarmId) {
-          this.dialogVisible = false
-          return
-        }
+        
+        // this.farmId = this.$cookie.get('farmId') === 'null'? undefined: parseInt(this.$cookie.get('farmId'))
+        // if (this.formFarmId) {
+          
+        //   return
+        // }
       },
       submit () {
         this.$refs['dataForm'].validate((valid) => {

+ 10 - 6
src/views/modules/alarm/temp.vue

@@ -8,7 +8,7 @@
             <el-form-item style="width: 180px">
               <el-input placeholder="耳标" v-model="form.earTag"></el-input>
             </el-form-item>
-            <el-form-item style="width: 140px">
+            <!-- <el-form-item style="width: 140px">
               <el-select placeholder="牧场" v-model="form.farmId" :disabled="farmId > 0" @change="farmChange">
                 <el-option
                   v-for="item in farmList"
@@ -17,7 +17,7 @@
                   :value="item.value">
                 </el-option>
               </el-select>
-            </el-form-item>
+            </el-form-item> -->
             <el-form-item style="width: 140px">
               <el-select placeholder="猪舍" v-model="form.pigstyId" @change="pigstyChange">
                 <el-option
@@ -86,12 +86,12 @@
               align="center"
               label="耳标">
             </el-table-column>
-            <el-table-column
+            <!-- <el-table-column
               prop="farmName"
               header-align="center"
               align="center"
               label="牧场">
-            </el-table-column>
+            </el-table-column> -->
             <el-table-column
               prop="pigstyName"
               header-align="center"
@@ -175,12 +175,16 @@
         labelPosition: 'right',
         thresholdTypes: [
           {
-            label: '高温',
+            label: '体温高温',
             value: 8
           },
           {
-            label: '低温',
+            label: '体温低温',
             value: 9
+          },
+          {
+            label: '耳标电量过低',
+            value: 10
           }
         ],
         verifyVisible: false, // 弹窗是否显示

+ 4 - 2
src/views/modules/basicdata/bpighouse.vue

@@ -206,7 +206,8 @@ export default {
         pastureResult.data.all && (this.pastureList = pastureResult.data.all)
         let employeeResult = await this.$http({
           url: this.$http.adornUrl("/management/employee/findAll"),
-          method: "post"
+          method: "get",
+          params: this.$http.adornParams({}, false)
         });
         employeeResult.data.all && (this.employeeList = employeeResult.data.all)
         console.log(this.employeeList);
@@ -266,7 +267,8 @@ export default {
           // 获取养殖员
           let employeeResult = await this.$http({
             url: this.$http.adornUrl("/management/employee/findAll"),
-            method: "post"
+            method: "get",
+            params: this.$http.adornParams({}, false)
           });
           employeeResult.data.all && (this.employeeList = employeeResult.data.all)
         }

+ 2 - 0
src/views/modules/breed/btransfer.vue

@@ -405,6 +405,8 @@
             }
             this.breedList.push(item)
           })
+          this.form.pigstyId? this.periodSelectedList = this.periodList.filter(item => item.pigstyId === this.form.pigstyId): this.periodSelectedList = this.periodList
+          this.form.pigstyId? this.unitSelectedList = this.unitList.filter(item => item.pigstyId === this.form.pigstyId): this.unitSelectedList = this.unitList
           // 获取猪只List
           if (data && data.code === 0) {
             this.dataList = data.page.list

+ 0 - 0
src/views/modules/env/camera.vue


+ 0 - 0
src/views/modules/env/huan.vue


+ 0 - 0
src/views/modules/env/meteo.vue


+ 0 - 0
src/views/modules/env/test.vue


+ 3 - 2
src/views/modules/envir/ealarm-add-or-update.vue

@@ -24,7 +24,7 @@
       </el-form-item>
       <el-form-item label="参数名称" prop="thresholdType">
         <!-- <el-input v-model.number="dataForm.thresholdType" placeholder="请输入数字"></el-input> -->
-        <el-select v-model="dataForm.thresholdType" :disabled="farmId > 0" style="width: 100%">
+        <el-select v-model="dataForm.thresholdType" style="width: 100%">
           <el-option
             v-for="item in thresholdTypes"
             :key="item.value"
@@ -151,7 +151,8 @@
               '6': 2,
               '7': 2,
               '8': 3,
-              '9': 3
+              '9': 3,
+              '10': 3
             }
             this.$http({
               url: this.$http.adornUrl(`/management/thresholdManagement/${!this.dataForm.id ? 'save' : 'update'}`),

+ 4 - 0
src/views/modules/envir/ealarm.vue

@@ -196,6 +196,10 @@
           {
             label: '体温低温',
             value: 9
+          },
+          {
+            label: '耳标电量过低',
+            value: 10
           }
         ]
       }

+ 6 - 4
src/views/modules/health/hvaccine.vue

@@ -24,13 +24,15 @@
           <el-form size="mini" :inline="true">
             <el-form-item>
               <el-button
-                  icon="el-icon-plus"
-                  @click="visible = true">
+                icon="el-icon-plus"
+                @click="visible = true">
                 新 增
               </el-button>
               <el-button
-                  icon="el-icon-delete"
-                  @click="delAll">
+                icon="el-icon-delete"
+                @click="delAll"
+                type="danger"
+                :disabled="selectList.length <= 0">
                 删 除
               </el-button>
             </el-form-item>

+ 492 - 0
src/views/modules/pigbasic/pbadopt-charts/in-and-out.vue

@@ -0,0 +1,492 @@
+<template>
+  <div class="in-and-out">
+    <!-- 入栏 / 出栏 饼状图 -->
+    <!-- <div id="J_chartPieBox" class="chart-box"></div> -->
+    <!-- <el-row :gutter="20"> -->
+      <!-- <el-col :span="24">
+        <el-card>
+          <div id="J_chartLineBox" class="chart-box"></div>
+        </el-card>
+      </el-col>
+      <el-col :span="24">
+        <el-card>
+          <div id="J_chartBarBox" class="chart-box"></div>
+        </el-card>
+      </el-col> -->
+      <!-- <el-col :span="24"> -->
+        <el-card>
+          <div id="J_chartPieBox" class="chart-box"></div>
+        </el-card>
+      <!-- </el-col> -->
+      <!-- <el-col :span="12">
+        <el-card>
+          <div id="J_chartScatterBox" class="chart-box"></div>
+        </el-card>
+      </el-col> -->
+    <!-- </el-row> -->
+  </div>
+</template>
+
+<script>
+  import echarts from 'echarts'
+  export default {
+    data () {
+      return {
+        chartLine: null,
+        chartBar: null,
+        chartPie: null,
+        chartScatter: null,
+        proportion: null
+      }
+    },
+    // props: ['proportion'],
+    // mounted () {
+    //   // this.initChartLine()
+    //   // this.initChartBar()
+    //   this.$nextTick(() => {
+    //     this.initChartPie()
+    //   })
+    //   // this.initChartScatter()
+    // },
+    mounted () {
+      // 由于给echart添加了resize事件, 在组件激活时需要重新resize绘画一次, 否则出现空白bug
+      // if (this.chartLine) {
+      //   this.chartLine.resize()
+      // }
+      // if (this.chartBar) {
+      //   this.chartBar.resize()
+      // }
+      // if (this.chartPie) {
+      //   this.$nextTick(() => {
+      //     this.chartPie.resize()
+      //   })
+        
+      // }
+      // this.$nextTick(() => {
+      this.initChartPie()
+      // })
+      // if (this.chartScatter) {
+      //   this.chartScatter.resize()
+      // }
+    },
+    methods: {
+      con() {
+        console.log(this.proportion)
+      },
+      // // 折线图
+      // initChartLine () {
+      //   var option = {
+      //     'title': {
+      //       'text': '折线图堆叠'
+      //     },
+      //     'tooltip': {
+      //       'trigger': 'axis'
+      //     },
+      //     'legend': {
+      //       'data': [ '邮件营销', '联盟广告', '视频广告', '直接访问', '搜索引擎' ]
+      //     },
+      //     'grid': {
+      //       'left': '3%',
+      //       'right': '4%',
+      //       'bottom': '3%',
+      //       'containLabel': true
+      //     },
+      //     'toolbox': {
+      //       'feature': {
+      //         'saveAsImage': { }
+      //       }
+      //     },
+      //     'xAxis': {
+      //       'type': 'category',
+      //       'boundaryGap': false,
+      //       'data': [ '周一', '周二', '周三', '周四', '周五', '周六', '周日' ]
+      //     },
+      //     'yAxis': {
+      //       'type': 'value'
+      //     },
+      //     'series': [
+      //       {
+      //         'name': '邮件营销',
+      //         'type': 'line',
+      //         'stack': '总量',
+      //         'data': [ 120, 132, 101, 134, 90, 230, 210 ]
+      //       },
+      //       {
+      //         'name': '联盟广告',
+      //         'type': 'line',
+      //         'stack': '总量',
+      //         'data': [ 220, 182, 191, 234, 290, 330, 310 ]
+      //       },
+      //       {
+      //         'name': '视频广告',
+      //         'type': 'line',
+      //         'stack': '总量',
+      //         'data': [ 150, 232, 201, 154, 190, 330, 410 ]
+      //       },
+      //       {
+      //         'name': '直接访问',
+      //         'type': 'line',
+      //         'stack': '总量',
+      //         'data': [ 320, 332, 301, 334, 390, 330, 320 ]
+      //       },
+      //       {
+      //         'name': '搜索引擎',
+      //         'type': 'line',
+      //         'stack': '总量',
+      //         'data': [ 820, 932, 901, 934, 1290, 1330, 1320 ]
+      //       }
+      //     ]
+      //   }
+      //   this.chartLine = echarts.init(document.getElementById('J_chartLineBox'))
+      //   this.chartLine.setOption(option)
+      //   window.addEventListener('resize', () => {
+      //     this.chartLine.resize()
+      //   })
+      // },
+      // // 柱状图
+      // initChartBar () {
+      //   var option = {
+      //     tooltip: {
+      //       trigger: 'axis',
+      //       axisPointer: {
+      //         type: 'shadow'
+      //       }
+      //     },
+      //     legend: {
+      //       data: ['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎', '百度', '谷歌', '必应', '其他']
+      //     },
+      //     grid: {
+      //       left: '3%',
+      //       right: '4%',
+      //       bottom: '3%',
+      //       containLabel: true
+      //     },
+      //     xAxis: [
+      //       {
+      //         type: 'category',
+      //         data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
+      //       }
+      //     ],
+      //     yAxis: [
+      //       {
+      //         type: 'value'
+      //       }
+      //     ],
+      //     series: [
+      //       {
+      //         name: '直接访问',
+      //         type: 'bar',
+      //         data: [320, 332, 301, 334, 390, 330, 320]
+      //       },
+      //       {
+      //         name: '邮件营销',
+      //         type: 'bar',
+      //         stack: '广告',
+      //         data: [120, 132, 101, 134, 90, 230, 210]
+      //       },
+      //       {
+      //         name: '联盟广告',
+      //         type: 'bar',
+      //         stack: '广告',
+      //         data: [220, 182, 191, 234, 290, 330, 310]
+      //       },
+      //       {
+      //         name: '视频广告',
+      //         type: 'bar',
+      //         stack: '广告',
+      //         data: [150, 232, 201, 154, 190, 330, 410]
+      //       },
+      //       {
+      //         name: '搜索引擎',
+      //         type: 'bar',
+      //         data: [862, 1018, 964, 1026, 1679, 1600, 1570],
+      //         markLine: {
+      //           lineStyle: {
+      //             normal: {
+      //               type: 'dashed'
+      //             }
+      //           },
+      //           data: [
+      //             [{ type: 'min' }, { type: 'max' }]
+      //           ]
+      //         }
+      //       },
+      //       {
+      //         name: '百度',
+      //         type: 'bar',
+      //         barWidth: 5,
+      //         stack: '搜索引擎',
+      //         data: [620, 732, 701, 734, 1090, 1130, 1120]
+      //       },
+      //       {
+      //         name: '谷歌',
+      //         type: 'bar',
+      //         stack: '搜索引擎',
+      //         data: [120, 132, 101, 134, 290, 230, 220]
+      //       },
+      //       {
+      //         name: '必应',
+      //         type: 'bar',
+      //         stack: '搜索引擎',
+      //         data: [60, 72, 71, 74, 190, 130, 110]
+      //       },
+      //       {
+      //         name: '其他',
+      //         type: 'bar',
+      //         stack: '搜索引擎',
+      //         data: [62, 82, 91, 84, 109, 110, 120]
+      //       }
+      //     ]
+      //   }
+      //   this.chartBar = echarts.init(document.getElementById('J_chartBarBox'))
+      //   this.chartBar.setOption(option)
+      //   window.addEventListener('resize', () => {
+      //     this.chartBar.resize()
+      //   })
+      // },
+      // 饼状图
+      initChartPie () {
+        // this.dataListLoading = true;
+        this.$http({
+          url: this.$http.adornUrl("/management/yearpigbase/outAndInProportion"),
+          method: "get",
+          params: this.$http.adornParams()
+        }).then( ({ data }) => {
+          console.log(data.data);
+          if (data && data.code === 0) {
+            this.proportion = data.data
+            var option = {
+              backgroundColor: '#2c343c',
+              title: {
+                text: '育肥出栏比例饼状图',
+                left: 'center',
+                top: 20,
+                textStyle: {
+                  color: '#fff'
+                }
+              },
+              tooltip: {
+                trigger: 'item',
+                formatter: '{a} <br/>{b} : {c} ({d}%)'
+              },
+              visualMap: {
+                show: false,
+                min: 80,
+                max: 600,
+                inRange: {
+                  colorLightness: [0, 1]
+                }
+              },
+              series: [
+                {
+                  name: '访问来源',
+                  type: 'pie',
+                  radius: '65%',
+                  center: ['50%', '55%'],
+                  data: [
+                    { value: this.proportion['inFenct'], name: '育肥' },
+                    { value: this.proportion['outFenct'], name: '出栏' },
+                    // { value: 274, name: '联盟广告' },
+                    // { value: 235, name: '视频广告' },
+                    // { value: 400, name: '搜索引擎' }
+                  ].sort(function (a, b) { return a.value - b.value }),
+                  roseType: 'radius',
+                  label: {
+                    normal: {
+                      textStyle: {
+                        color: 'rgba(255, 255, 255, 0.8)'
+                      }
+                    }
+                  },
+                  labelLine: {
+                    normal: {
+                      lineStyle: {
+                        color: 'rgba(255, 255, 255, 0.8)'
+                      },
+                      smooth: 0.2,
+                      length: 10,
+                      length2: 20
+                    }
+                  },
+                  itemStyle: {
+                    normal: {
+                      color: '#c23531',
+                      shadowBlur: 200,
+                      shadowColor: 'rgba(0, 0, 0, 0.5)'
+                    }
+                  },
+                  animationType: 'scale',
+                  animationEasing: 'elasticOut',
+                  animationDelay: function (idx) {
+                    return Math.random() * 200
+                  }
+                }
+              ]
+            }
+            this.chartPie = echarts.init(document.getElementById('J_chartPieBox'))
+            this.chartPie.setOption(option)
+            window.addEventListener('resize', () => {
+              this.chartPie.resize()
+            })
+          } else {
+            this.proportion = null
+          }
+        })
+        
+      },
+      // // 散点图
+      // initChartScatter () {
+      //   var option = {
+      //     backgroundColor: new echarts.graphic.RadialGradient(0.3, 0.3, 0.8, [
+      //       { offset: 0, color: '#f7f8fa' },
+      //       { offset: 1, color: '#cdd0d5' }
+      //     ]),
+      //     title: {
+      //       text: '1990 与 2015 年各国家人均寿命与 GDP'
+      //     },
+      //     legend: {
+      //       right: 10,
+      //       data: ['1990', '2015']
+      //     },
+      //     xAxis: {
+      //       splitLine: {
+      //         lineStyle: {
+      //           type: 'dashed'
+      //         }
+      //       }
+      //     },
+      //     yAxis: {
+      //       splitLine: {
+      //         lineStyle: {
+      //           type: 'dashed'
+      //         }
+      //       },
+      //       scale: true
+      //     },
+      //     series: [
+      //       {
+      //         name: '1990',
+      //         data: [
+      //           [28604, 77, 17096869, 'Australia', 1990],
+      //           [31163, 77.4, 27662440, 'Canada', 1990],
+      //           [1516, 68, 1154605773, 'China', 1990],
+      //           [13670, 74.7, 10582082, 'Cuba', 1990],
+      //           [28599, 75, 4986705, 'Finland', 1990],
+      //           [29476, 77.1, 56943299, 'France', 1990],
+      //           [31476, 75.4, 78958237, 'Germany', 1990],
+      //           [28666, 78.1, 254830, 'Iceland', 1990],
+      //           [1777, 57.7, 870601776, 'India', 1990],
+      //           [29550, 79.1, 122249285, 'Japan', 1990],
+      //           [2076, 67.9, 20194354, 'North Korea', 1990],
+      //           [12087, 72, 42972254, 'South Korea', 1990],
+      //           [24021, 75.4, 3397534, 'New Zealand', 1990],
+      //           [43296, 76.8, 4240375, 'Norway', 1990],
+      //           [10088, 70.8, 38195258, 'Poland', 1990],
+      //           [19349, 69.6, 147568552, 'Russia', 1990],
+      //           [10670, 67.3, 53994605, 'Turkey', 1990],
+      //           [26424, 75.7, 57110117, 'United Kingdom', 1990],
+      //           [37062, 75.4, 252847810, 'United States', 1990]
+      //         ],
+      //         type: 'scatter',
+      //         symbolSize: function (data) {
+      //           return Math.sqrt(data[2]) / 5e2
+      //         },
+      //         label: {
+      //           emphasis: {
+      //             show: true,
+      //             formatter: function (param) {
+      //               return param.data[3]
+      //             },
+      //             position: 'top'
+      //           }
+      //         },
+      //         itemStyle: {
+      //           normal: {
+      //             shadowBlur: 10,
+      //             shadowColor: 'rgba(120, 36, 50, 0.5)',
+      //             shadowOffsetY: 5,
+      //             color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [
+      //               { offset: 0, color: 'rgb(251, 118, 123)' },
+      //               { offset: 1, color: 'rgb(204, 46, 72)' }
+      //             ])
+      //           }
+      //         }
+      //       },
+      //       {
+      //         name: '2015',
+      //         data: [
+      //           [44056, 81.8, 23968973, 'Australia', 2015],
+      //           [43294, 81.7, 35939927, 'Canada', 2015],
+      //           [13334, 76.9, 1376048943, 'China', 2015],
+      //           [21291, 78.5, 11389562, 'Cuba', 2015],
+      //           [38923, 80.8, 5503457, 'Finland', 2015],
+      //           [37599, 81.9, 64395345, 'France', 2015],
+      //           [44053, 81.1, 80688545, 'Germany', 2015],
+      //           [42182, 82.8, 329425, 'Iceland', 2015],
+      //           [5903, 66.8, 1311050527, 'India', 2015],
+      //           [36162, 83.5, 126573481, 'Japan', 2015],
+      //           [1390, 71.4, 25155317, 'North Korea', 2015],
+      //           [34644, 80.7, 50293439, 'South Korea', 2015],
+      //           [34186, 80.6, 4528526, 'New Zealand', 2015],
+      //           [64304, 81.6, 5210967, 'Norway', 2015],
+      //           [24787, 77.3, 38611794, 'Poland', 2015],
+      //           [23038, 73.13, 143456918, 'Russia', 2015],
+      //           [19360, 76.5, 78665830, 'Turkey', 2015],
+      //           [38225, 81.4, 64715810, 'United Kingdom', 2015],
+      //           [53354, 79.1, 321773631, 'United States', 2015]
+      //         ],
+      //         type: 'scatter',
+      //         symbolSize: function (data) {
+      //           return Math.sqrt(data[2]) / 5e2
+      //         },
+      //         label: {
+      //           emphasis: {
+      //             show: true,
+      //             formatter: function (param) {
+      //               return param.data[3]
+      //             },
+      //             position: 'top'
+      //           }
+      //         },
+      //         itemStyle: {
+      //           normal: {
+      //             shadowBlur: 10,
+      //             shadowColor: 'rgba(25, 100, 150, 0.5)',
+      //             shadowOffsetY: 5,
+      //             color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [
+      //               { offset: 0, color: 'rgb(129, 227, 238)' },
+      //               { offset: 1, color: 'rgb(25, 183, 207)' }
+      //             ])
+      //           }
+      //         }
+      //       }
+      //     ]
+      //   }
+      //   this.chartPie = echarts.init(document.getElementById('J_chartScatterBox'))
+      //   this.chartPie.setOption(option)
+      //   window.addEventListener('resize', () => {
+      //     this.chartPie.resize()
+      //   })
+      // }
+    }
+  }
+</script>
+
+<style lang="scss">
+  .in-and-out {
+    // > .el-alert {
+    //   margin-bottom: 10px;
+    // }
+    // > .el-row {
+    //   margin-top: -10px;
+    //   margin-bottom: -10px;
+    //   .el-col {
+    //     padding-top: 10px;
+    //     padding-bottom: 10px;
+    //   }
+    // }
+    .chart-box {
+      min-height: 640px;
+    }
+  }
+</style>

+ 488 - 0
src/views/modules/pigbasic/pbadopt-charts/statistics.vue

@@ -0,0 +1,488 @@
+<template>
+  <div class="in-and-out">
+    <!-- 入栏 / 出栏 饼状图 -->
+    <!-- <div id="J_chartPieBox" class="chart-box"></div> -->
+    <!-- <el-row :gutter="20"> -->
+      <!-- <el-col :span="24"> -->
+        <el-card>
+          <div id="J_chartLineBox" class="chart-box"></div>
+        </el-card>
+      <!-- </el-col> -->
+      <!-- <el-col :span="24">
+        <el-card>
+          <div id="J_chartBarBox" class="chart-box"></div>
+        </el-card>
+      </el-col> -->
+      <!-- <el-col :span="24"> -->
+        <!-- <el-card>
+          <div id="J_chartPieBox" class="chart-box"></div>
+        </el-card> -->
+      <!-- </el-col> -->
+      <!-- <el-col :span="12">
+        <el-card>
+          <div id="J_chartScatterBox" class="chart-box"></div>
+        </el-card>
+      </el-col> -->
+    <!-- </el-row> -->
+  </div>
+</template>
+
+<script>
+  import echarts from 'echarts'
+  export default {
+    data () {
+      return {
+        chartLine: null,
+        // chartBar: null,
+        // chartPie: null,
+        // chartScatter: null,
+        statistics: null,
+        date: [],
+        total: []
+      }
+    },
+    // props: ['proportion'],
+    // mounted () {
+    //   // this.initChartLine()
+    //   // this.initChartBar()
+    //   this.$nextTick(() => {
+    //     this.initChartPie()
+    //   })
+    //   // this.initChartScatter()
+    // },
+    mounted () {
+      // 由于给echart添加了resize事件, 在组件激活时需要重新resize绘画一次, 否则出现空白bug
+      // if (this.chartLine) {
+      //   this.chartLine.resize()
+      // }
+      // if (this.chartBar) {
+      //   this.chartBar.resize()
+      // }
+      // if (this.chartPie) {
+      //   this.$nextTick(() => {
+      //     this.chartPie.resize()
+      //   })
+        
+      // }
+      // this.$nextTick(() => {
+      this.initChartLine()
+      // })
+      // if (this.chartScatter) {
+      //   this.chartScatter.resize()
+      // }
+    },
+    methods: {
+      con() {
+        console.log(this.proportion)
+      },
+      // // 折线图
+      initChartLine () {
+        this.date = []
+        this.total = []
+        this.$http({
+          url: this.$http.adornUrl("/management/yearpigbase/suchStatisticsMonth"),
+          method: "get",
+          params: this.$http.adornParams()
+        }).then( ({ data }) => {
+          console.log(data.data);
+          if (data && data.code === 0) {
+            data.data.forEach(item => {
+              this.date.push(item.date)
+              this.total.push(item.total)
+            })
+            var option = {
+              'title': {
+                'text': '出栏统计折线图'
+              },
+              'tooltip': {
+                'trigger': 'axis'
+              },
+              'legend': {
+                'data': [ '出栏猪只数量']
+              },
+              'grid': {
+                'left': '3%',
+                'right': '4%',
+                'bottom': '3%',
+                'containLabel': true
+              },
+              'toolbox': {
+                'feature': {
+                  'saveAsImage': { }
+                }
+              },
+              'xAxis': {
+                'type': 'category',
+                'boundaryGap': false,
+                'data': this.date
+              },
+              'yAxis': {
+                'type': 'value'
+              },
+              'series': [
+                {
+                  'name': '出栏猪只数量',
+                  'type': 'line',
+                  'stack': '总量',
+                  'data': this.total,
+                  symbolSize: 8,
+                  smooth: true
+                }
+              ]
+            }
+            this.chartLine = echarts.init(document.getElementById('J_chartLineBox'))
+            this.chartLine.setOption(option)
+            window.addEventListener('resize', () => {
+              this.chartLine.resize()
+            })
+          }
+        })
+        
+      },
+      // // 柱状图
+      // initChartBar () {
+      //   var option = {
+      //     tooltip: {
+      //       trigger: 'axis',
+      //       axisPointer: {
+      //         type: 'shadow'
+      //       }
+      //     },
+      //     legend: {
+      //       data: ['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎', '百度', '谷歌', '必应', '其他']
+      //     },
+      //     grid: {
+      //       left: '3%',
+      //       right: '4%',
+      //       bottom: '3%',
+      //       containLabel: true
+      //     },
+      //     xAxis: [
+      //       {
+      //         type: 'category',
+      //         data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
+      //       }
+      //     ],
+      //     yAxis: [
+      //       {
+      //         type: 'value'
+      //       }
+      //     ],
+      //     series: [
+      //       {
+      //         name: '直接访问',
+      //         type: 'bar',
+      //         data: [320, 332, 301, 334, 390, 330, 320]
+      //       },
+      //       {
+      //         name: '邮件营销',
+      //         type: 'bar',
+      //         stack: '广告',
+      //         data: [120, 132, 101, 134, 90, 230, 210]
+      //       },
+      //       {
+      //         name: '联盟广告',
+      //         type: 'bar',
+      //         stack: '广告',
+      //         data: [220, 182, 191, 234, 290, 330, 310]
+      //       },
+      //       {
+      //         name: '视频广告',
+      //         type: 'bar',
+      //         stack: '广告',
+      //         data: [150, 232, 201, 154, 190, 330, 410]
+      //       },
+      //       {
+      //         name: '搜索引擎',
+      //         type: 'bar',
+      //         data: [862, 1018, 964, 1026, 1679, 1600, 1570],
+      //         markLine: {
+      //           lineStyle: {
+      //             normal: {
+      //               type: 'dashed'
+      //             }
+      //           },
+      //           data: [
+      //             [{ type: 'min' }, { type: 'max' }]
+      //           ]
+      //         }
+      //       },
+      //       {
+      //         name: '百度',
+      //         type: 'bar',
+      //         barWidth: 5,
+      //         stack: '搜索引擎',
+      //         data: [620, 732, 701, 734, 1090, 1130, 1120]
+      //       },
+      //       {
+      //         name: '谷歌',
+      //         type: 'bar',
+      //         stack: '搜索引擎',
+      //         data: [120, 132, 101, 134, 290, 230, 220]
+      //       },
+      //       {
+      //         name: '必应',
+      //         type: 'bar',
+      //         stack: '搜索引擎',
+      //         data: [60, 72, 71, 74, 190, 130, 110]
+      //       },
+      //       {
+      //         name: '其他',
+      //         type: 'bar',
+      //         stack: '搜索引擎',
+      //         data: [62, 82, 91, 84, 109, 110, 120]
+      //       }
+      //     ]
+      //   }
+      //   this.chartBar = echarts.init(document.getElementById('J_chartBarBox'))
+      //   this.chartBar.setOption(option)
+      //   window.addEventListener('resize', () => {
+      //     this.chartBar.resize()
+      //   })
+      // },
+      // // 饼状图
+      // initChartPie () {
+      //   // this.dataListLoading = true;
+      //   this.$http({
+      //     url: this.$http.adornUrl("/management/yearpigbase/outAndInProportion"),
+      //     method: "get",
+      //     params: this.$http.adornParams()
+      //   }).then( ({ data }) => {
+      //     console.log(data.data);
+      //     if (data && data.code === 0) {
+      //       this.proportion = data.data
+      //       var option = {
+      //         backgroundColor: '#2c343c',
+      //         title: {
+      //           text: '育肥出栏比例饼状图',
+      //           left: 'center',
+      //           top: 20,
+      //           textStyle: {
+      //             color: '#fff'
+      //           }
+      //         },
+      //         tooltip: {
+      //           trigger: 'item',
+      //           formatter: '{a} <br/>{b} : {c} ({d}%)'
+      //         },
+      //         visualMap: {
+      //           show: false,
+      //           min: 80,
+      //           max: 600,
+      //           inRange: {
+      //             colorLightness: [0, 1]
+      //           }
+      //         },
+      //         series: [
+      //           {
+      //             name: '访问来源',
+      //             type: 'pie',
+      //             radius: '65%',
+      //             center: ['50%', '55%'],
+      //             data: [
+      //               { value: this.proportion['inFenct'], name: '育肥' },
+      //               { value: this.proportion['outFenct'], name: '出栏' },
+      //               // { value: 274, name: '联盟广告' },
+      //               // { value: 235, name: '视频广告' },
+      //               // { value: 400, name: '搜索引擎' }
+      //             ].sort(function (a, b) { return a.value - b.value }),
+      //             roseType: 'radius',
+      //             label: {
+      //               normal: {
+      //                 textStyle: {
+      //                   color: 'rgba(255, 255, 255, 0.8)'
+      //                 }
+      //               }
+      //             },
+      //             labelLine: {
+      //               normal: {
+      //                 lineStyle: {
+      //                   color: 'rgba(255, 255, 255, 0.8)'
+      //                 },
+      //                 smooth: 0.2,
+      //                 length: 10,
+      //                 length2: 20
+      //               }
+      //             },
+      //             itemStyle: {
+      //               normal: {
+      //                 color: '#c23531',
+      //                 shadowBlur: 200,
+      //                 shadowColor: 'rgba(0, 0, 0, 0.5)'
+      //               }
+      //             },
+      //             animationType: 'scale',
+      //             animationEasing: 'elasticOut',
+      //             animationDelay: function (idx) {
+      //               return Math.random() * 200
+      //             }
+      //           }
+      //         ]
+      //       }
+      //       this.chartPie = echarts.init(document.getElementById('J_chartPieBox'))
+      //       this.chartPie.setOption(option)
+      //       window.addEventListener('resize', () => {
+      //         this.chartPie.resize()
+      //       })
+      //     } else {
+      //       this.proportion = null
+      //     }
+      //   })
+        
+      // },
+      // // 散点图
+      // initChartScatter () {
+      //   var option = {
+      //     backgroundColor: new echarts.graphic.RadialGradient(0.3, 0.3, 0.8, [
+      //       { offset: 0, color: '#f7f8fa' },
+      //       { offset: 1, color: '#cdd0d5' }
+      //     ]),
+      //     title: {
+      //       text: '1990 与 2015 年各国家人均寿命与 GDP'
+      //     },
+      //     legend: {
+      //       right: 10,
+      //       data: ['1990', '2015']
+      //     },
+      //     xAxis: {
+      //       splitLine: {
+      //         lineStyle: {
+      //           type: 'dashed'
+      //         }
+      //       }
+      //     },
+      //     yAxis: {
+      //       splitLine: {
+      //         lineStyle: {
+      //           type: 'dashed'
+      //         }
+      //       },
+      //       scale: true
+      //     },
+      //     series: [
+      //       {
+      //         name: '1990',
+      //         data: [
+      //           [28604, 77, 17096869, 'Australia', 1990],
+      //           [31163, 77.4, 27662440, 'Canada', 1990],
+      //           [1516, 68, 1154605773, 'China', 1990],
+      //           [13670, 74.7, 10582082, 'Cuba', 1990],
+      //           [28599, 75, 4986705, 'Finland', 1990],
+      //           [29476, 77.1, 56943299, 'France', 1990],
+      //           [31476, 75.4, 78958237, 'Germany', 1990],
+      //           [28666, 78.1, 254830, 'Iceland', 1990],
+      //           [1777, 57.7, 870601776, 'India', 1990],
+      //           [29550, 79.1, 122249285, 'Japan', 1990],
+      //           [2076, 67.9, 20194354, 'North Korea', 1990],
+      //           [12087, 72, 42972254, 'South Korea', 1990],
+      //           [24021, 75.4, 3397534, 'New Zealand', 1990],
+      //           [43296, 76.8, 4240375, 'Norway', 1990],
+      //           [10088, 70.8, 38195258, 'Poland', 1990],
+      //           [19349, 69.6, 147568552, 'Russia', 1990],
+      //           [10670, 67.3, 53994605, 'Turkey', 1990],
+      //           [26424, 75.7, 57110117, 'United Kingdom', 1990],
+      //           [37062, 75.4, 252847810, 'United States', 1990]
+      //         ],
+      //         type: 'scatter',
+      //         symbolSize: function (data) {
+      //           return Math.sqrt(data[2]) / 5e2
+      //         },
+      //         label: {
+      //           emphasis: {
+      //             show: true,
+      //             formatter: function (param) {
+      //               return param.data[3]
+      //             },
+      //             position: 'top'
+      //           }
+      //         },
+      //         itemStyle: {
+      //           normal: {
+      //             shadowBlur: 10,
+      //             shadowColor: 'rgba(120, 36, 50, 0.5)',
+      //             shadowOffsetY: 5,
+      //             color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [
+      //               { offset: 0, color: 'rgb(251, 118, 123)' },
+      //               { offset: 1, color: 'rgb(204, 46, 72)' }
+      //             ])
+      //           }
+      //         }
+      //       },
+      //       {
+      //         name: '2015',
+      //         data: [
+      //           [44056, 81.8, 23968973, 'Australia', 2015],
+      //           [43294, 81.7, 35939927, 'Canada', 2015],
+      //           [13334, 76.9, 1376048943, 'China', 2015],
+      //           [21291, 78.5, 11389562, 'Cuba', 2015],
+      //           [38923, 80.8, 5503457, 'Finland', 2015],
+      //           [37599, 81.9, 64395345, 'France', 2015],
+      //           [44053, 81.1, 80688545, 'Germany', 2015],
+      //           [42182, 82.8, 329425, 'Iceland', 2015],
+      //           [5903, 66.8, 1311050527, 'India', 2015],
+      //           [36162, 83.5, 126573481, 'Japan', 2015],
+      //           [1390, 71.4, 25155317, 'North Korea', 2015],
+      //           [34644, 80.7, 50293439, 'South Korea', 2015],
+      //           [34186, 80.6, 4528526, 'New Zealand', 2015],
+      //           [64304, 81.6, 5210967, 'Norway', 2015],
+      //           [24787, 77.3, 38611794, 'Poland', 2015],
+      //           [23038, 73.13, 143456918, 'Russia', 2015],
+      //           [19360, 76.5, 78665830, 'Turkey', 2015],
+      //           [38225, 81.4, 64715810, 'United Kingdom', 2015],
+      //           [53354, 79.1, 321773631, 'United States', 2015]
+      //         ],
+      //         type: 'scatter',
+      //         symbolSize: function (data) {
+      //           return Math.sqrt(data[2]) / 5e2
+      //         },
+      //         label: {
+      //           emphasis: {
+      //             show: true,
+      //             formatter: function (param) {
+      //               return param.data[3]
+      //             },
+      //             position: 'top'
+      //           }
+      //         },
+      //         itemStyle: {
+      //           normal: {
+      //             shadowBlur: 10,
+      //             shadowColor: 'rgba(25, 100, 150, 0.5)',
+      //             shadowOffsetY: 5,
+      //             color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [
+      //               { offset: 0, color: 'rgb(129, 227, 238)' },
+      //               { offset: 1, color: 'rgb(25, 183, 207)' }
+      //             ])
+      //           }
+      //         }
+      //       }
+      //     ]
+      //   }
+      //   this.chartPie = echarts.init(document.getElementById('J_chartScatterBox'))
+      //   this.chartPie.setOption(option)
+      //   window.addEventListener('resize', () => {
+      //     this.chartPie.resize()
+      //   })
+      // }
+    }
+  }
+</script>
+
+<style lang="scss">
+  .in-and-out {
+    // > .el-alert {
+    //   margin-bottom: 10px;
+    // }
+    // > .el-row {
+    //   margin-top: -10px;
+    //   margin-bottom: -10px;
+    //   .el-col {
+    //     padding-top: 10px;
+    //     padding-bottom: 10px;
+    //   }
+    // }
+    .chart-box {
+      min-height: 640px;
+    }
+  }
+</style>

+ 119 - 0
src/views/modules/pigbasic/pbadopt.vue

@@ -0,0 +1,119 @@
+<template>
+  <div class="bpighouse">
+    <div class="rect rect-table">
+      <!-- 按钮:入栏/出栏 or 出栏统计 -->
+      <el-form inline size="mini">
+        <el-form-item>
+          <el-button
+            type="danger"
+            @click="inOut = !inOut"
+            :disabled="inOut">
+            育肥 / 出栏
+          </el-button>
+        </el-form-item>
+        <el-form-item>
+          <el-button 
+            type="danger"
+            @click="inOut = !inOut"
+            :disabled="!inOut">
+            出栏统计
+          </el-button>
+        </el-form-item>
+      </el-form>
+      <!-- 入栏 / 出栏 饼状图 -->
+      <in-and-out v-if="inOut"></in-and-out>
+      <statistics v-else></statistics>
+    </div>
+  </div>
+</template>
+<script>
+import InAndOut from './pbadopt-charts/in-and-out.vue'
+import Statistics from './pbadopt-charts/statistics.vue'
+export default {
+  data() {
+    return {
+      inOut: true
+    }
+  },
+  components: {
+    InAndOut,
+    Statistics
+  },
+  activated() {
+    // this.getDataList();
+  },
+  methods: {
+    // 获取入栏 \ 出栏 饼状图的数据
+    // getDataList() {
+    //   // this.dataListLoading = true;
+    //   this.$http({
+    //     url: this.$http.adornUrl("/management/yearpigbase/outAndInProportion"),
+    //     method: "get",
+    //     params: this.$http.adornParams()
+    //   }).then( ({ data }) => {
+    //     console.log(data.data);
+    //     if (data && data.code === 0) {
+    //       this.proportion = data.data
+    //     } else {
+    //       this.proportion = null
+    //     }
+    //   })
+    // },
+    
+  }
+}
+</script>
+<style scoped>
+.rect {
+  background-color: #fff;
+  padding: 30px 15px;
+  border-radius: 5px;
+  border: 1px solid #e8e8e8;
+  margin-left: 20px;
+}
+.rect-form {
+  padding-bottom: 10px;
+}
+/* .rect-table {
+  margin-top: 20px;
+} */
+.demo-table-expand {
+  font-size: 0;
+  margin-left: 40px;
+}
+.demo-table-expand label {
+  width: 90px;
+  color: #99a9bf;
+}
+.demo-table-expand .el-form-item {
+  margin-right: 0;
+  margin-bottom: 0;
+  width: 80%;
+}
+.el-table .height {
+  background: rgba(254, 254, 254, 0.5);
+}
+/deep/ .el-table--mini td, .el-table--mini th {
+  padding: 3px 0 !important;
+  height: 20px !important;
+}
+/deep/ .el-checkbox__input.is-checked+.el-checkbox__label {
+  color: rgb(24,144,255);
+  background-color: rgb(24,144,255);
+  border-color: rgb(24,144,255);
+}
+/deep/.el-table .el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner {
+  background-color: rgb(24,144,255);
+  border-color: rgb(24,144,255);
+}
+/deep/.el-table .el-checkbox__inner:hover {
+  border-color: rgb(24,144,255);
+}
+/deep/.el-table .el-checkbox__input.is-focus .el-checkbox__inner {
+  border-color: rgb(24,144,255);
+}
+/deep/.el-table #select .cell .el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner {
+  background-color: rgb(24,144,255);
+  border-color: rgb(24,144,255);
+}
+</style>

+ 14 - 250
src/views/modules/pigbasic/pbbasic.vue

@@ -83,18 +83,9 @@
                 </el-option>
               </el-select>
             </el-form-item>
-              <!-- <el-button 
-                icon="el-icon-search"
-                type="danger" 
-                style="background-color: rgb(24,144,255);color: #fff;border-color: rgb(24,144,255);width: 90px;height: 30px;font-size: 13px">
-                查 询
-              </el-button> -->
               <el-button @click="getDataList()" icon="el-icon-search">查 询</el-button>
             </el-form-item>
             <el-form-item>
-              <!-- <el-button 
-                icon="el-icon-circle-close" 
-                style="background-color: rgb(24,144,255);color: #fff;border-color: rgb(24,144,255);width: 90px;height: 30px;font-size: 13px">清 空</el-button> -->
                 <el-button icon="el-icon-circle-close" @click="clearAll">清 空</el-button>
             </el-form-item>
           </el-form>
@@ -104,32 +95,16 @@
       <el-main>
         <div class="rect" style="margin-top: 20px">
           <el-form size="mini" :inline="true">
-            <!-- <el-form-item>
-              <el-button
-                v-if="isAuth('sys:role:save')"
-                type="primary"
-                @click="addOrUpdateHandle()"
-                icon="el-icon-plus">
-                新增
-              </el-button>
-            </el-form-item>
-            <el-form-item>
-              <el-button
-                v-if="isAuth('sys:role:delete')"
-                type="success"
-                @click="deleteHandle()"
-                :disabled="selectionDataList.length <= 0" 
-                icon="el-icon-delete">
-                批量删除
-              </el-button>
-            </el-form-item> -->
             <el-form-item>
               <el-button 
                 icon="el-icon-plus">
                 新 增
               </el-button>
               <el-button 
-                icon="el-icon-delete">
+                icon="el-icon-delete"
+                type="danger"
+                @click="deleteHandle()"
+                :disabled="selectionDataList.length <= 0">
                 删 除
               </el-button>
             </el-form-item>
@@ -148,183 +123,6 @@
             :header-cell-style="{background:'rgb(245,245,245)',color:'#000',height: '45px',fontSize: '13px',fontWeight: 'normal',borderBottom: '1px solid #ccc'}" 
             :cell-style="{color: '#888',fontSize: '13px'}"
             size="mini">
-            <!-- <el-table-column
-              type="selection"
-              header-align="center"
-              align="center"
-              width="50">
-            </el-table-column>
-            <el-table-column type="expand" style="background-color: #eee">
-              <template slot-scope="props">
-                <div style="background-color: rgb(250, 250, 250)">
-                  
-                <el-form
-                  :label-position="labelPosition"
-                  inline
-                  class="demo-table-expand"
-                  label-width="120px">
-                  <el-row>
-                    <el-col :span="12">
-                      <el-form-item label="耳标:">
-                        <span>{{ props.row.eartag }}</span>
-                      </el-form-item>
-                    </el-col>
-                    <el-col :span="12">
-                      <el-form-item label="年龄:">
-                        <span>{{ props.row.dayAge }}天</span>
-                      </el-form-item>
-                    </el-col>
-                  </el-row>
-                  <el-row>
-                    <el-col :span="12">
-                      <el-form-item label="健康状况:">
-                        <span>{{
-                          props.row.healthStatus ? "健康" : "不健康"
-                        }}</span>
-                      </el-form-item>
-                    </el-col>
-                    <el-col :span="12">
-                      <el-form-item label="体重:">
-                        <span>{{ props.row.weight }}千克</span>
-                      </el-form-item>
-                    </el-col>
-                  </el-row>
-                  <el-row>
-                    <el-col :span="12">
-                      <el-form-item label="品种:">
-                        <span>{{ props.row.breed }}</span>
-                      </el-form-item>
-                    </el-col>
-                    <el-col :span="12">
-                      <el-form-item label="去向:">
-                        <span>{{ props.row.whereDidYouGo }}</span>
-                      </el-form-item>
-                    </el-col>
-                  </el-row>
-                  <el-row>
-                    <el-col :span="12">
-                      <el-form-item label="所属单元:">
-                        <span>{{ props.row.unitNumber }}</span>
-                      </el-form-item>
-                    </el-col>
-                    <el-col :span="12">
-                      <el-form-item label="所属猪舍:">
-                        <span>{{ props.row.phNumber }}</span>
-                      </el-form-item>
-                    </el-col>
-                  </el-row>
-                  <el-form-item label="所属牧场:">
-                    <span>{{ props.row.name }}</span>
-                  </el-form-item> -->
-                  <!-- 三列保留 -->
-                  <!-- <el-row>
-                  <el-col span="8">
-                    <el-form-item label="耳标">
-                      <span>{{ props.row.eartag }}</span>
-                    </el-form-item>
-                  </el-col>
-                  <el-col span="8">
-                    <el-form-item label="年龄">
-                      <span>{{ props.row.dayAge }}天</span>
-                    </el-form-item>
-                  </el-col>
-                  <el-col span="8">
-                    <el-form-item label="健康状况">
-                      <span>{{ props.row.healthStatus? '健康': '不健康' }}</span>
-                    </el-form-item>
-                  </el-col>
-                </el-row>
-                <el-row>
-                  
-                  <el-col span="8">
-                    <el-form-item label="体重">
-                      <span>{{ props.row.weight }}千克</span>
-                    </el-form-item>
-                  </el-col>
-                  <el-col span="8">
-                    <el-form-item label="品种">
-                      <span>{{ props.row.breed }}</span>
-                    </el-form-item>
-                  </el-col>
-                  <el-col span="8">
-                    <el-form-item label="去向">
-                      <span>{{ props.row.whereDidYouGo }}</span>
-                    </el-form-item>
-                  </el-col>
-                </el-row>
-                <el-row>
-                  <el-col span="8">
-                    <el-form-item label="所属单元">
-                      <span>{{ props.row.unitNumber }}</span>
-                    </el-form-item>
-                  </el-col>
-                  <el-col span="8">
-                    <el-form-item label="所属猪舍">
-                      <span>{{ props.row.phNumber }}</span>
-                    </el-form-item>
-                  </el-col>
-                  <el-col span="8">
-                    <el-form-item label="所属牧场">
-                      <span>{{ props.row.name }}</span>
-                    </el-form-item>
-                  </el-col>
-                </el-row> -->
-
-                  <!-- <el-form-item label="健康状况">
-                  <span>{{ props.row.healthStatus? '健康': '不健康' }}</span>
-                </el-form-item> -->
-                  <!-- <el-form-item label="体重">
-                  <span>{{ props.row.weight }}千克</span>
-                </el-form-item> -->
-                  <!-- <el-form-item label="品种">
-                  <span>{{ props.row.breed }}</span>
-                </el-form-item> -->
-                  <!-- <el-form-item label="去向">
-                  <span>{{ props.row.whereDidYouGo }}</span>
-                </el-form-item> -->
-                  <!-- <el-form-item label="所属单元">
-                  <span>{{ props.row.unitNumber }}</span>
-                </el-form-item> -->
-                  <!-- <el-form-item label="所属猪舍">
-                  <span>{{ props.row.phNumber }}</span>
-                </el-form-item> -->
-                  <!-- <el-form-item label="所属牧场">
-                  <span>{{ props.row.name }}</span>
-                </el-form-item> -->
-                <!-- </el-form>
-                </div>
-              </template>
-            </el-table-column>
-            <el-table-column
-              prop="eartag"
-              header-align="center"
-              align="center"
-              label="年猪耳标">
-            </el-table-column>
-            <el-table-column
-              prop="periodNumber"
-              header-align="center"
-              align="center"
-              label="所属栏期">
-            </el-table-column>
-            <el-table-column
-              prop="unitNumber"
-              header-align="center"
-              align="center"
-              label="所属单元">
-            </el-table-column>
-            <el-table-column
-              prop="phNumber"
-              header-align="center"
-              align="center"
-              label="所属猪舍">
-            </el-table-column>
-            <el-table-column
-              prop="name"
-              header-align="center"
-              align="center"
-              label="所属牧场">
-            </el-table-column> -->
             <el-table-column
               type="selection"
               header-align="center"
@@ -446,21 +244,6 @@
               label-width="80px"
               size="mini"
               style="padding: 0 60px 0 40px">
-              <!-- <el-form-item label="所属牧场" prop="farmId">
-                <el-select
-                  v-model="form.farmId"
-                  placeholder="请选择所属牧场"
-                  @change="getPasture"
-                  ref="pasture"
-                  style="width: 100%">
-                  <el-option
-                    v-for="item in pastureList"
-                    :key="item.id"
-                    :label="item.name"
-                    :value="item.id">
-                  </el-option>
-                </el-select>
-              </el-form-item> -->
               <el-form-item label="所属猪舍" prop="pigstyId">
                 <el-select
                   v-model="form.pigstyId"
@@ -533,10 +316,6 @@
                   style="width: 100%">
                 </el-date-picker>
               </el-form-item>
-              <!-- <el-form-item label="年龄">
-              <el-input v-model="form.dayAge" placeholder="请输入年龄(天)"></el-input>
-              <el-input-number v-model="form.dayAge" :step="1" :max="10000000000" :min="0" @change="changeDay"></el-input-number> 天
-            </el-form-item> -->
               <el-form-item label="健康状况" prop="healthStatus">
                 <el-select
                   v-model="form.healthStatus"
@@ -559,7 +338,6 @@
                   style="width: 85%">
                 </el-input-number>
                 千克
-                <!-- <el-input v-model="form.weight" placeholder="请输入体重(千克)"></el-input> -->
               </el-form-item>
               <el-form-item label="品种" prop="breed">
                 <el-input
@@ -568,9 +346,6 @@
                   style="width: 100%">
                 </el-input>
               </el-form-item>
-              <!-- <el-form-item label="去向">
-              <el-input v-model="form.whereDidYouGo" placeholder="请输入去向"></el-input>
-            </el-form-item> -->
             </el-form>
             <span slot="footer" class="dialog-footer">
               <el-button @click="cancel" style="background-color: rgb(24,144,255);color: #fff;border-color: rgb(24,144,255)">关闭</el-button>
@@ -579,26 +354,24 @@
           </el-dialog>
         </div>
       </el-main>
-      <!-- </el-container> -->
     </el-container>
   </div>
 </template>
 
 <script>
-// import pbbasicLeft from "./pbbasicLeft";
 
 export default {
   data() {
     return {
       searchForm: {
         eartag: '',
-        gender: '',
-        breeding: '',
-        health: '',
-        breedStatus: '',
-        period: '',
-        pighouse: '',
-        unit: ''
+        sex: '',
+        breed: '',
+        healthStatus: '',
+        outFenceStatus: '',
+        periodId: '',
+        pigstyId: '',
+        unitId: ''
       },
       dataList: [],
       pageIndex: 1,
@@ -713,9 +486,6 @@ export default {
     },
     // 获取数据列表
     getDataList() {
-      console.log(this.$store.state.user.id);
-      console.log(this.$store.state.user.name);
-      console.log(this.$cookie.get('token'));
       this.dataListLoading = true;
       // 获取所有猪只信息
       this.$http({
@@ -727,8 +497,8 @@ export default {
           'eartag': this.searchForm.eartag || undefined,
           'sex': this.searchForm.sex || undefined,
           'breed': this.searchForm.breed || undefined,
-          'healthStatus': this.searchForm.healthStatus || undefined,
-          'outFenceStatus': this.searchForm.outFenceStatus || undefined,
+          'healthStatus': this.searchForm.healthStatus || (this.searchForm.healthStatus === 0?this.searchForm.healthStatus: undefined),
+          'outFenceStatus': this.searchForm.outFenceStatus || (this.searchForm.outFenceStatus === 0?this.searchForm.outFenceStatus: undefined),
           'periodId': this.searchForm.periodId || undefined,
           'pigstyId': this.searchForm.pigstyId || undefined,
           'unitId': this.searchForm.unitId || undefined
@@ -786,6 +556,7 @@ export default {
           this.periodList.push(item)
         })
         this.searchForm.pigstyId? this.periodSelectedList = this.periodList.filter(item => item.pigstyId === this.searchForm.pigstyId): this.periodSelectedList = this.periodList
+        this.searchForm.pigstyId? this.unitSelectedList = this.unitList.filter(item => item.pigstyId === this.searchForm.pigstyId): this.unitSelectedList = this.unitList
         // 品种list
         this.breedList = []
         let breedList = []
@@ -890,13 +661,6 @@ export default {
       }
       console.log(val);
     },
-    // 变色
-    tableRowClassName({ row, rowIndex }) {
-      if (rowIndex % 2 === 0) {
-        return "warning-row";
-      }
-      return "";
-    },
     // 获取出生日期
     changeBirth(val) {
       let birth = new Date(val);

+ 62 - 57
src/views/modules/pigbasic/pbentry-add-or-update.vue

@@ -40,14 +40,14 @@
           style="width: 100%"
           @change="ifPigsty('unitId')">
           <el-option
-            v-for="item in unitList"
+            v-for="item in unitSelectedList"
             :key="item.value"
             :label="item.label"
             :value="item.value">
           </el-option>
         </el-select>
       </el-form-item>
-      <el-form-item label="栏期" prop="periodId">
+      <!-- <el-form-item label="栏期" prop="periodId">
         <el-select 
           v-model="dataForm.periodId"
           style="width: 100%" 
@@ -59,7 +59,7 @@
             :value="item.value">
           </el-option>
         </el-select>
-      </el-form-item>
+      </el-form-item> -->
       <el-form-item label="性别" prop="sex">
         <el-select 
           v-model="dataForm.sex"
@@ -104,7 +104,7 @@
         </el-input-number>
         千克
       </el-form-item>
-      <el-form-item label="产地" prop="originPlace">
+      <!-- <el-form-item label="产地" prop="originPlace">
         <el-select 
           v-model="dataForm.originPlace"
           style="width: 100%">
@@ -115,7 +115,7 @@
             :value="item.value">
           </el-option>
         </el-select>
-      </el-form-item>
+      </el-form-item> -->
       <el-form-item label="品种" prop="breed">
         <el-select 
           v-model="dataForm.breed"
@@ -164,11 +164,11 @@
           eartag: '',
           pigstyId: '',
           unitId: '',
-          periodId: '',
-          sex: '',
+          // periodId: '',
+          sex: '',
           birthday: '',
-          healthStatus: true,
-          weight: '',
+          healthStatus: 1,
+          weight: 5,
           originPlace: '',
           breed: '',
           outFenceStatus: 0,
@@ -185,8 +185,20 @@
           unitId: [
             { required: true, message: '单元不能为空', trigger: 'blur' }
           ],
-          periodId: [
-            { required: true, message: '栏期不能为空', trigger: 'blur' }
+          // periodId: [
+          //   { required: true, message: '栏期不能为空', trigger: 'blur' }
+          // ],
+          healthStatus: [
+            { required: true, message: '健康状态不能为空', trigger: 'blur' }
+          ],
+          outFenceStatus: [
+            { required: true, message: '健康状态不能为空', trigger: 'blur' }
+          ],
+          sex: [
+            { required: true, message: '性别不能为空', trigger: 'blur' }
+          ],
+          weight: [
+            { required: true, message: '体重不能为空', trigger: 'blur' }
           ]
         },
         gender: [
@@ -202,28 +214,19 @@
         pigstyList: [], // 栋舍List
         unitList: [], // 单元List
         unitSelectedList: [], // 单元SelectedList
-        periodList: [], // 栏期List
-        periodSelectedList: [], // 栏期SelectedList
+        // periodList: [], // 栏期List
+        // periodSelectedList: [], // 栏期SelectedList
         healthStatus: [
           {
-            value: true,
+            value: 1,
             label: '健康'
           },
           {
-            value: false,
+            value: 0,
             label: '不健康'
           }
         ],
-        breedList: [
-          {
-            value: 1,
-            label: '杜巴嘉'
-          },
-          {
-            value: 2,
-            label: '长白'
-          }
-        ], // 品种List
+        breedList: [], // 品种List
         originPlaceList: [], // 产地List
         outFenceStatus: [
           {
@@ -266,12 +269,12 @@
             this.dataForm.eartag = data.yearPigBase.eartag
             this.dataForm.pigstyId = data.yearPigBase.pigstyId
             this.dataForm.unitId = data.yearPigBase.unitId
-            this.dataForm.periodId = data.yearPigBase.periodId
+            // this.dataForm.periodId = data.yearPigBase.periodId
             this.dataForm.sex = data.yearPigBase.sex
             this.dataForm.birthday = data.yearPigBase.birthday
             this.dataForm.healthStatus = data.yearPigBase.healthStatus
             this.dataForm.weight = data.yearPigBase.weight
-            this.dataForm.originPlace = data.yearPigBase.originPlace
+            // this.dataForm.originPlace = data.yearPigBase.originPlace
             this.dataForm.breed = data.yearPigBase.breed
             this.dataForm.outFenceStatus = data.yearPigBase.outFenceStatus
             this.dataForm.motherEartag = data.yearPigBase.motherEartag
@@ -313,35 +316,36 @@
             this.unitList.push(item)
           })
           this.unitSelectedList = this.unitList
-          // 栏期List
-          this.periodList = []
-          let periodList = []
-          let periodR = await this.$http({
-            url: this.$http.adornUrl("/management/period/findAll"),
-            method: "get",
-            params: this.$http.adornParams({})
+          // 品种list
+          let breedList = []
+          let bloodR = await this.$http({
+            url: this.$http.adornUrl(`/management/basebloodline/findAll`),
+            method: 'get',
+            params: this.$http.adornParams({}, false)
           })
-          periodR.data.all && (periodList = periodR.data.all)
-          periodList.forEach(period => {
+          bloodR.data.all && (breedList = bloodR.data.all)
+          this.breedList = []
+          // this.originPlaceList = []
+          breedList.forEach(breed => {
             let item = {
-              value: period.id,
-              label: period.number,
-              pigstyId: period.pigstyId
+              value: breed.name,
+              label: breed.name,
+              origin: breed.origin
             }
-            this.periodList.push(item)
+            // let item02 = {
+            //   value: breed.origin,
+            //   label: breed.origin
+            // }
+            this.breedList.push(item)
+            // this.originPlaceList.push(item02)
           })
-          this.periodSelectedList = this.periodList
-
-
-
-
-          
         })
       },
       // 根据栋舍选择限制单元和栏期
       pigstyChange (val) {
         this.unitSelectedList = this.unitList.filter(item => item.pigstyId === val)
-        this.periodSelectedList = this.periodList.filter(item => item.pigstyId === val)
+        console.log(this.unitSelectedList);
+        // this.periodSelectedList = this.periodList.filter(item => item.pigstyId === val)
       },
       // 需要先选择猪舍,才能选择单元或栏期
       ifPigsty (val) {
@@ -363,21 +367,22 @@
                 'farmId': parseInt(this.$cookie.get('formFarmId')),
                 'pigstyId': this.dataForm.pigstyId,
                 'unitId': this.dataForm.unitId,
-                'periodId': this.dataForm.periodId,
-                'sex': this.dataForm.sex,
-                'birthday': this.dataForm.birthday,
+                // 'periodId': this.dataForm.periodId,
+                'sex': this.dataForm.sex || undefined,
+                'birthday': this.dataForm.birthday || undefined,
                 'healthStatus': this.dataForm.healthStatus,
                 'weight': this.dataForm.weight,
-                'originPlace': this.dataForm.originPlace,
-                'breed': this.dataForm.breed,
-                'outFenceTime': this.dataForm.outFenceTime,
-                'motherEartag': this.dataForm.motherEartag,
-                'fatherEartag': this.dataForm.fatherEartag
+                'originPlace': this.dataForm.breed? (this.breedList.filter(item => item.value === this.dataForm.breed))[0].origin: undefined,
+                'breed': this.dataForm.breed || undefined,
+                'outFenceStatus': this.dataForm.outFenceStatus,
+                'motherEartag': this.dataForm.motherEartag || undefined,
+                'fatherEartag': this.dataForm.fatherEartag || undefined
               })
             }).then(({data}) => {
               if (data && data.code === 0) {
                 this.visible = false
-                this.$emit('refreshDataList')
+                let addLength = this.dataForm.eartag.split(',').length
+                this.$emit('refreshDataList', `${!this.dataForm.id? 'add-' + addLength: ''}`)
                 this.$message({
                   message: '操作成功',
                   type: 'success',
@@ -418,7 +423,7 @@
         handler(newValue, oldValue) {
           if (oldValue) {
             this.dataForm.unitId = ''
-            this.dataForm.periodId = ''
+            // this.dataForm.periodId = ''
           }
         }
       }

+ 36 - 7
src/views/modules/pigbasic/pbentry.vue

@@ -294,11 +294,11 @@
         ],
         healthStatus: [
           {
-            value: true,
+            value: 1,
             label: '健康'
           },
           {
-            value: false,
+            value: 0,
             label: '不健康'
           }
         ],
@@ -328,17 +328,44 @@
     },
     methods: {
       // 获取数据列表
-      getDataList () {
+      getDataList (val) {
         this.dataListLoading = true
+        // 如果是新增
+        // if (val === 'add') {
+        //   this.pageIndex = (this.dataList.length % this.pageSize === 0? this.totalPage + 1: this.totalPage)
+        //   console.log(this.pageIndex);
+        // } else if (val === 'del') {
+        //   this.pageIndex = Math.ceil((this.dataList.length - this.delLength) / this.pageSize)
+        // }
+        
+        // 对 新增or删除 操作,当前页为最后一页
+        if (val) {
+          let valArr = val.split('-')
+          let total = 0
+          if (valArr[0] === 'add') {
+            total = this.totalPage + parseInt(valArr[1])
+          } else if (valArr[0] === 'del') {
+            total = this.totalPage - parseInt(valArr[1])
+          }
+          this.pageIndex = Math.ceil(total / this.pageSize)
+        }
         this.$http({
           url: this.$http.adornUrl('/management/yearpigbase/list'),
           method: 'get',
           params: this.$http.adornParams({
             'page': this.pageIndex,
-            'limit': this.pageSize
+            'limit': this.pageSize,
+            'eartag': this.form.eartag || undefined,
+            'sex': this.form.sex || undefined,
+            'breed': this.form.breed || undefined,
+            'healthStatus': this.form.healthStatus || (this.form.healthStatus === 0?this.form.healthStatus: undefined),
+            'outFenceStatus': this.form.outFenceStatus || (this.form.outFenceStatus === 0?this.form.outFenceStatus: undefined),
+            'periodId': this.form.periodId || undefined,
+            'pigstyId': this.form.pigstyId || undefined,
+            'unitId': this.form.unitId || undefined
           })
         }).then(async({data}) => {
-          // 栋舍List
+          // 舍List
           this.pigstyList = []
           let pigstyList = []
           let pigstyR = await this.$http({
@@ -389,7 +416,8 @@
             }
             this.periodList.push(item)
           })
-          this.periodSelectedList = this.periodList
+          this.form.pigstyId? this.periodSelectedList = this.periodList.filter(item => item.pigstyId === this.form.pigstyId): this.periodSelectedList = this.periodList
+          this.form.pigstyId? this.unitSelectedList = this.unitList.filter(item => item.pigstyId === this.form.pigstyId): this.unitSelectedList = this.unitList
           // 获取猪只List
           if (data && data.code === 0) {
             this.dataList = data.page.list
@@ -455,6 +483,7 @@
         var ids = id ? [id] : this.dataListSelections.map(item => {
           return item.id
         })
+        let delLength = this.dataListSelections.length
         this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
           confirmButtonText: '确定',
           cancelButtonText: '取消',
@@ -474,7 +503,7 @@
                 //   this.getDataList()
                 // }
               })
-              this.getDataList()
+              this.getDataList('del-' + delLength)
             } else {
               this.$message.error(data.msg)
             }

+ 581 - 0
src/views/modules/pigbasic/pbexit.vue

@@ -0,0 +1,581 @@
+<template>
+  <div class="mod-role">
+    <el-container>
+      <!-- form表单 -->
+      <el-header>
+        <div class="rect rect-form">
+          <el-form :inline="true" :model="form" @keyup.enter.native="getDataList()" size="mini" ref="form">
+            <el-form-item>
+              <el-input v-model="form.eartag" placeholder="耳标" clearable></el-input>
+            </el-form-item>
+            <el-form-item style="width: 140px">
+              <el-select placeholder="性别" v-model="form.sex">
+                <el-option
+                  v-for="item in gender"
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value">
+                </el-option>
+              </el-select>
+            </el-form-item>
+            <el-form-item style="width: 140px">
+              <el-select placeholder="品种" v-model="form.breed">
+                <el-option
+                  v-for="item in breed"
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value">
+                </el-option>
+              </el-select>
+            </el-form-item>
+            <el-form-item style="width: 140px">
+              <el-select placeholder="健康状态" v-model="form.healthStatus">
+                <el-option
+                  v-for="item in healthStatus"
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value">
+                </el-option>
+              </el-select>
+            </el-form-item>
+            <el-form-item style="width: 140px">
+              <el-select placeholder="养殖状态" v-model="form.outFenceStatus">
+                <el-option
+                  v-for="item in outFenceStatus"
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value">
+                </el-option>
+              </el-select>
+            </el-form-item>
+            <el-form-item style="width: 140px">
+              <el-select placeholder="猪舍" v-model="form.pigstyId" @change="pigstyChange">
+                <el-option
+                  v-for="item in pigstyList"
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value">
+                </el-option>
+              </el-select>
+            </el-form-item>
+            <el-form-item style="width: 140px">
+              <el-select placeholder="单元" v-model="form.unitId" @change="ifPigsty('unitId')">
+                <el-option
+                  v-for="item in unitSelectedList"
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value">
+                </el-option>
+              </el-select>
+            </el-form-item>
+            <el-form-item style="width: 140px">
+              <el-select placeholder="栏期" v-model="form.periodId" @change="ifPigsty('periodId')">
+                <el-option
+                  v-for="item in periodSelectedList"
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value">
+                </el-option>
+              </el-select>
+            </el-form-item>
+
+            <el-form-item>
+              <el-button @click="getDataList()" icon="el-icon-search">查 询</el-button>
+            </el-form-item>
+            <el-form-item>
+              <el-button 
+                icon="el-icon-circle-close"
+                @click="clearAll">清 空</el-button>
+            </el-form-item>
+          </el-form>
+        </div>
+      </el-header>
+      <!-- role表格 -->
+      <el-main>
+        <div class="rect rect-table">
+          <!-- 新增 删除按钮 -->
+          <el-form inline size="mini">
+            <!-- <el-form-item>
+              <el-button 
+                icon="el-icon-plus" 
+                @click="addOrUpdateHandle()">
+                新 增
+              </el-button>
+            </el-form-item> -->
+            <el-form-item>
+              <el-button 
+                icon="el-icon-d-arrow-right" 
+                type="danger" 
+                @click="deleteHandle()" 
+                :disabled="dataListSelections.length <= 0">
+                出 栏
+              </el-button>
+            </el-form-item>
+            <!-- <el-form-item>
+              <el-button 
+                icon="el-icon-edit" 
+                type="danger" 
+                @click="addOrUpdateHandle()" 
+                :disabled="dataListSelections.length <= 0">
+                批量修改
+              </el-button>
+            </el-form-item> -->
+          </el-form>
+          
+          <el-table
+            :data="dataList"
+            border
+            stripe
+            v-loading="dataListLoading"
+            @selection-change="selectionChangeHandle"
+            style="width: 100%;"
+            size="mini"
+            height="540"
+            :header-cell-style="{background:'rgb(245,245,245)',color:'#000',height: '45px',fontSize: '13px',fontWeight: 'normal',borderBottom: '1px solid #ccc'}" 
+            :cell-style="{color: '#888',fontSize: '13px'}">
+            <el-table-column
+              type="selection"
+              header-align="center"
+              align="center"
+              width="50">
+            </el-table-column>
+            <el-table-column
+              prop="id"
+              header-align="center"
+              align="center"
+              label="id"
+              width="80">
+            </el-table-column>
+            <el-table-column
+              prop="eartag"
+              header-align="center"
+              align="center"
+              label="耳标">
+            </el-table-column>
+            <el-table-column
+              prop="sex"
+              header-align="center"
+              align="center"
+              label="性别"
+              width="80">
+            </el-table-column>
+            <el-table-column
+              prop="birthday"
+              header-align="center"
+              align="center"
+              label="出生日期">
+            </el-table-column>
+            <el-table-column
+              header-align="center"
+              align="center"
+              label="健康状态"
+              width="100">
+              <template slot-scope="scope">
+                <span>{{scope.row.healthStatus? '健康': '不健康'}}</span>
+              </template>
+            </el-table-column>
+            <el-table-column
+              header-align="center"
+              align="center"
+              label="养殖状态"
+              width="100">
+              <template slot-scope="scope">
+                <span>{{scope.row.outFenceStatus? '出栏': '育肥'}}</span>
+              </template>
+            </el-table-column>
+            <el-table-column
+              prop="breed"
+              header-align="center"
+              align="center"
+              label="品种"
+              width="100">
+            </el-table-column>
+            <el-table-column
+              prop="pigstyName"
+              header-align="center"
+              align="center"
+              label="猪舍">
+            </el-table-column>
+            <el-table-column
+              prop="unitName"
+              header-align="center"
+              align="center"
+              label="单元">
+            </el-table-column>
+            <el-table-column
+              prop="periodName"
+              header-align="center"
+              align="center"
+              label="栏期">
+            </el-table-column>
+            <el-table-column
+              fixed="right"
+              header-align="center"
+              align="center"
+              label="操作">
+              <template slot-scope="scope">
+                <!-- <el-button
+                  type="text"
+                  size="medium"
+                  style="color: rgb(24,144,255)">
+                  查看
+                </el-button> -->
+                <el-button
+                  type="text"
+                  size="medium"
+                  @click="deleteHandle(scope.row)"
+                  style="color: rgb(24,144,255)">
+                  出栏
+                </el-button>
+              </template>
+            </el-table-column>
+          </el-table>
+          <el-pagination
+            @size-change="sizeChangeHandle"
+            @current-change="currentChangeHandle"
+            :current-page="pageIndex"
+            :page-sizes="[10, 20, 50, 100]"
+            :page-size="pageSize"
+            :total="totalPage"
+            layout="total, sizes, prev, pager, next, jumper">
+          </el-pagination>
+          <!-- 弹窗, 新增 / 修改 -->
+          <!-- <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update> -->
+        </div>
+      </el-main>
+      
+      
+    </el-container>
+  </div>
+</template>
+
+<script>
+  // import AddOrUpdate from './pbentry-add-or-update'
+  export default {
+    data () {
+      return {
+        form: {
+          eartag: '',
+          sex: '',
+          breed: '',
+          healthStatus: '',
+          outFenceStatus: '',
+          periodId: '',
+          pigstyId: '',
+          unitId: ''
+        },
+        dataList: [],
+        pageIndex: 1,
+        pageSize: 10,
+        totalPage: 0,
+        dataListLoading: false,
+        dataListSelections: [],
+        addOrUpdateVisible: false,
+        farmId: undefined,
+        gender: [
+          {
+            value: '公',
+            label: '公'
+          },
+          {
+            value: '母',
+            label: '母'
+          }
+        ],
+        breed: [
+          {
+            value: 1,
+            label: '杜巴嘉'
+          },
+          {
+            value: 2,
+            label: '长白'
+          }
+        ],
+        healthStatus: [
+          {
+            value: 1,
+            label: '健康'
+          },
+          {
+            value: 0,
+            label: '不健康'
+          }
+        ],
+        outFenceStatus: [
+          {
+            value: 0,
+            label: '育肥'
+          },
+          {
+            value: 1,
+            label: '出栏'
+          }
+        ],
+        periodList: [], // 所有栏期
+        periodSelectedList: [], // 根据栋舍限制的栏期
+        pigstyList: [], // 所有栋舍
+        unitList: [], // 所有单元
+        unitSelectedList: [], // 根据栋舍限制的单元
+        labelPosition: 'right'
+      }
+    },
+    // components: {
+    //   AddOrUpdate
+    // },
+    activated () {
+      this.getDataList()
+    },
+    methods: {
+      // 获取数据列表
+      getDataList () {
+        this.dataListLoading = true
+        // 如果是新增
+        // if (val === 'add') {
+        //   this.pageIndex = (this.dataList.length % this.pageSize === 0? this.totalPage + 1: this.totalPage)
+        //   console.log(this.pageIndex);
+        // } else if (val === 'del') {
+        //   this.pageIndex = Math.ceil((this.dataList.length - this.delLength) / this.pageSize)
+        // }
+        
+        // 对 新增or删除 操作,当前页为最后一页
+        // if (val) {
+        //   let valArr = val.split('-')
+        //   let total = 0
+        //   if (valArr[0] === 'add') {
+        //     total = this.totalPage + parseInt(valArr[1])
+        //   } else if (valArr[0] === 'del') {
+        //     total = this.totalPage - parseInt(valArr[1])
+        //   }
+        //   this.pageIndex = Math.ceil(total / this.pageSize)
+        // }
+        this.$http({
+          url: this.$http.adornUrl('/management/yearpigbase/fattenList'),
+          method: 'get',
+          params: this.$http.adornParams({
+            'page': this.pageIndex,
+            'limit': this.pageSize,
+            'eartag': this.form.eartag || undefined,
+            'sex': this.form.sex || undefined,
+            'breed': this.form.breed || undefined,
+            'healthStatus': this.form.healthStatus || (this.form.healthStatus === 0?this.form.healthStatus: undefined),
+            'outFenceStatus': this.form.outFenceStatus || (this.form.outFenceStatus === 0?this.form.outFenceStatus: undefined),
+            'periodId': this.form.periodId || undefined,
+            'pigstyId': this.form.pigstyId || undefined,
+            'unitId': this.form.unitId || undefined
+          })
+        }).then(async({data}) => {
+          // 猪舍List
+          this.pigstyList = []
+          let pigstyList = []
+          let pigstyR = await this.$http({
+            url: this.$http.adornUrl("/management/pigsty/findAll"),
+            method: "get",
+            params: this.$http.adornParams({})
+          })
+          pigstyR.data.all && (pigstyList = pigstyR.data.all)
+          pigstyList.forEach(pigsty => {
+            let item = {
+              value: pigsty.id,
+              label: pigsty.number
+            }
+            this.pigstyList.push(item)
+          })
+          // 单元List
+          this.unitList = []
+          let unitList = []
+          let unitR = await this.$http({
+            url: this.$http.adornUrl("/management/unit/findAll"),
+            method: "get",
+            params: this.$http.adornParams({})
+          })
+          unitR.data.all && (unitList = unitR.data.all)
+          unitList.forEach(unit => {
+            let item = {
+              value: unit.id,
+              label: unit.number,
+              pigstyId: unit.pigstyId
+            }
+            this.unitList.push(item)
+          })
+          this.unitSelectedList = this.unitList
+          // 栏期List
+          this.periodList = []
+          let periodList = []
+          let periodR = await this.$http({
+            url: this.$http.adornUrl("/management/period/findAll"),
+            method: "get",
+            params: this.$http.adornParams({})
+          })
+          periodR.data.all && (periodList = periodR.data.all)
+          periodList.forEach(period => {
+            let item = {
+              value: period.id,
+              label: period.number,
+              pigstyId: period.pigstyId
+            }
+            this.periodList.push(item)
+          })
+          this.form.pigstyId? this.periodSelectedList = this.periodList.filter(item => item.pigstyId === this.form.pigstyId): this.periodSelectedList = this.periodList
+          this.form.pigstyId? this.unitSelectedList = this.unitList.filter(item => item.pigstyId === this.form.pigstyId): this.unitSelectedList = this.unitList
+          // 获取猪只List
+          if (data && data.code === 0) {
+            this.dataList = data.page.list
+            this.totalPage = data.page.totalCount
+          } else {
+            this.dataList = []
+            this.totalPage = 0
+            this.$message.error(data.msg)
+          }
+          this.dataListLoading = false
+        })
+      },
+      // 根据栋舍选择限制单元和栏期
+      pigstyChange (val) {
+        this.unitSelectedList = this.unitList.filter(item => item.pigstyId === val)
+        this.periodSelectedList = this.periodList.filter(item => item.pigstyId === val)
+      },
+      // 需要先选择猪舍,才能选择单元或栏期
+      ifPigsty (val) {
+        if (!this.form.pigstyId) {
+          this.$message.error('请先选择猪舍')
+          this.form[val] = ''
+        }
+      },
+      // form表单清空,单元SelectedList 和 栏期SelectedList重置
+      clearAll () {
+        for (let i in this.form) {
+          this.form[i] = ''
+        }
+        this.unitSelectedList = this.unitList
+        this.periodSelectedList = this.periodList
+      },
+      // 每页数
+      sizeChangeHandle (val) {
+        this.pageSize = val
+        this.pageIndex = 1
+        this.getDataList()
+      },
+      // 当前页
+      currentChangeHandle (val) {
+        this.pageIndex = val
+        this.getDataList()
+      },
+      // 多选
+      selectionChangeHandle (val) {
+        this.dataListSelections = val
+      },
+      // // 新增 / 修改
+      // addOrUpdateHandle (id) {
+      //   this.addOrUpdateVisible = true
+      //   var ids = id ? [id] : this.dataListSelections.map(item => {
+      //     return {
+      //       id: item.id,
+      //       eartag: item.eartag
+      //     }
+      //   })
+      //   this.$nextTick(() => {
+      //     this.$refs.addOrUpdate.init(ids)
+      //   })
+      // },
+      // 出栏
+      deleteHandle (pig) {
+        var ids = pig ? [pig.id] : this.dataListSelections.map(item => {
+          return item.id
+        })
+        var eartags = pig ? [pig.eartag] : this.dataListSelections.map(item => {
+          return item.eartag
+        })
+        let delLength = this.dataListSelections.length
+        this.$confirm(`确定对[耳标=${eartags.join(',')}]进行[${pig ? '出栏' : '批量出栏'}]操作?`, '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          this.$http({
+            url: this.$http.adornUrl('/management/yearpigbase/such'),
+            method: 'post',
+            data: this.$http.adornData(ids, false)
+          }).then(({data}) => {
+            if (data && data.code === 0) {
+              this.$message({
+                message: '操作成功',
+                type: 'success',
+                duration: 1500,
+                // onClose: () => {
+                //   this.getDataList()
+                // }
+              })
+              this.getDataList()
+            } else {
+              this.$message.error(data.msg)
+            }
+          })
+        }).catch(() => {})
+      }
+    },
+    watch: {
+      'form.pigstyId': {
+        handler(newValue, oldValue) {
+          if (oldValue) {
+            this.form.unitId = ''
+            this.form.periodId = ''
+          }
+        }
+      }
+    }
+  }
+</script>
+<style scoped>
+.rect {
+  background-color: #fff;
+  padding: 30px 15px;
+  border-radius: 5px;
+  border: 1px solid #e8e8e8;
+}
+.rect-form {
+  padding-bottom: 10px;
+}
+.rect-table {
+  margin-top: 20px;
+}
+.demo-table-expand {
+  font-size: 0;
+  margin-left: 40px;
+}
+.demo-table-expand label {
+  width: 90px;
+  color: #99a9bf;
+}
+.demo-table-expand .el-form-item {
+  margin-right: 0;
+  margin-bottom: 0;
+  width: 80%;
+}
+.el-table .height {
+  background: rgba(254, 254, 254, 0.5);
+}
+/deep/ .el-table--mini td, .el-table--mini th {
+  padding: 3px 0 !important;
+  height: 20px !important;
+}
+/deep/ .el-checkbox__input.is-checked+.el-checkbox__label {
+  color: rgb(24,144,255);
+  background-color: rgb(24,144,255);
+  border-color: rgb(24,144,255);
+}
+/deep/.el-table .el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner {
+  background-color: rgb(24,144,255);
+  border-color: rgb(24,144,255);
+}
+/deep/.el-table .el-checkbox__inner:hover {
+  border-color: rgb(24,144,255);
+}
+/deep/.el-table .el-checkbox__input.is-focus .el-checkbox__inner {
+  border-color: rgb(24,144,255);
+}
+/deep/.el-table #select .cell .el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner {
+  background-color: rgb(24,144,255);
+  border-color: rgb(24,144,255);
+}
+</style>

+ 44 - 39
src/views/modules/pigbasic/pbpedigree.vue

@@ -331,12 +331,15 @@
           method: 'get',
           params: this.$http.adornParams({
             'page': this.pageIndex,
-            'limit': this.pageSize
-            // 'username': this.form.username,
-            // 'departmentCode': this.form.departmentCode,
-            // 'jobCode': this.form.jobCode,
-            // 'sex': this.form.gender,
-            // 'farmId': this.farmId
+            'limit': this.pageSize,
+            'eartag': this.form.eartag || undefined,
+            'sex': this.form.sex || undefined,
+            'breed': this.form.breed || undefined,
+            'healthStatus': this.form.healthStatus || (this.form.healthStatus === 0?this.form.healthStatus: undefined),
+            'outFenceStatus': this.form.outFenceStatus || (this.form.outFenceStatus === 0?this.form.outFenceStatus: undefined),
+            'periodId': this.form.periodId || undefined,
+            'pigstyId': this.form.pigstyId || undefined,
+            'unitId': this.form.unitId || undefined
           })
         }).then(async({data}) => {
           // // 获取所有牧场
@@ -399,6 +402,8 @@
             this.periodList.push(item)
           })
           this.periodSelectedList = this.periodList
+          this.form.pigstyId? this.periodSelectedList = this.periodList.filter(item => item.pigstyId === this.form.pigstyId): this.periodSelectedList = this.periodList
+          this.form.pigstyId? this.unitSelectedList = this.unitList.filter(item => item.pigstyId === this.form.pigstyId): this.unitSelectedList = this.unitList
           // 获取猪只List
           if (data && data.code === 0) {
             this.dataList = data.page.list
@@ -408,39 +413,39 @@
             this.totalPage = 0
             this.$message.error(data.msg)
           }
-          // 猪只信息与单元、牧场、栏期、栋舍对应
-          this.dataList.forEach((item) => {
-            // 单元对应
-            for (let unit of this.unitList) {
-              if (item.unitId === unit.value) {
-                item.unitNumber = unit.label;
-                item.farmId = unit.farmId;
-                item.pigstyId = unit.pigstyId;
-                break;
-              }
-            }
-            // // 牧场对应
-            // for (let pasture of pastureList) {
-            //   if (item.farmId === pasture.id) {
-            //     item.name = pasture.name;
-            //     break;
-            //   }
-            // }
-            // 栋舍对应
-            for (let pighouse of this.pigstyList) {
-              if (item.pigstyId === pighouse.value) {
-                item.phNumber = pighouse.label;
-                break;
-              }
-            }
-            // 栏期对应
-            for (let period of this.periodList) {
-              if (item.periodId === period.value) {
-                item.periodNumber = period.label;
-                break;
-              }
-            }
-          })
+          // // 猪只信息与单元、牧场、栏期、栋舍对应
+          // this.dataList.forEach((item) => {
+          //   // 单元对应
+          //   for (let unit of this.unitList) {
+          //     if (item.unitId === unit.value) {
+          //       item.unitNumber = unit.label;
+          //       item.farmId = unit.farmId;
+          //       item.pigstyId = unit.pigstyId;
+          //       break;
+          //     }
+          //   }
+          //   // // 牧场对应
+          //   // for (let pasture of pastureList) {
+          //   //   if (item.farmId === pasture.id) {
+          //   //     item.name = pasture.name;
+          //   //     break;
+          //   //   }
+          //   // }
+          //   // 栋舍对应
+          //   for (let pighouse of this.pigstyList) {
+          //     if (item.pigstyId === pighouse.value) {
+          //       item.phNumber = pighouse.label;
+          //       break;
+          //     }
+          //   }
+          //   // 栏期对应
+          //   for (let period of this.periodList) {
+          //     if (item.periodId === period.value) {
+          //       item.periodNumber = period.label;
+          //       break;
+          //     }
+          //   }
+          // })
           this.dataListLoading = false
         })
       },

+ 0 - 223
src/views/modules/pigbasic/pbzhong-add-or-update.vue

@@ -77,123 +77,6 @@
         <el-input v-model="dataForm.remark">
         </el-input>
       </el-form-item>
-
-      <!-- <el-form-item label="猪舍" prop="pigstyId">
-        <el-select 
-          v-model="dataForm.pigstyId"
-          style="width: 100%"
-          @change="pigstyChange">
-          <el-option
-            v-for="item in pigstyList"
-            :key="item.value"
-            :label="item.label"
-            :value="item.value">
-          </el-option>
-        </el-select>
-      </el-form-item>
-      <el-form-item label="单元" prop="unitId">
-        <el-select 
-          v-model="dataForm.unitId"
-          style="width: 100%"
-          @change="ifPigsty('unitId')">
-          <el-option
-            v-for="item in unitList"
-            :key="item.value"
-            :label="item.label"
-            :value="item.value">
-          </el-option>
-        </el-select>
-      </el-form-item>
-      <el-form-item label="栏期" prop="periodId">
-        <el-select 
-          v-model="dataForm.periodId"
-          style="width: 100%" 
-          @change="ifPigsty('periodId')">
-          <el-option
-            v-for="item in periodList"
-            :key="item.value"
-            :label="item.label"
-            :value="item.value">
-          </el-option>
-        </el-select>
-      </el-form-item>
-      <el-form-item label="性别" prop="sex">
-        <el-select 
-          v-model="dataForm.sex"
-          style="width: 100%">
-          <el-option
-            v-for="item in gender"
-            :key="item.value"
-            :label="item.label"
-            :value="item.value">
-          </el-option>
-        </el-select>
-      </el-form-item> -->
-      
-      <!-- <el-form-item label="健康状态" prop="healthStatus">
-        <el-select 
-          v-model="dataForm.healthStatus"
-          style="width: 100%">
-          <el-option
-            v-for="item in healthStatus"
-            :key="item.value"
-            :label="item.label"
-            :value="item.value">
-          </el-option>
-        </el-select>
-      </el-form-item>
-      <el-form-item label="体重" prop="weight">
-        <el-input-number
-          v-model="dataForm.weight"
-          :step="0.01"
-          :max="1000000"
-          :min="0"
-          style="width: 91%">
-        </el-input-number>
-        千克
-      </el-form-item>
-      <el-form-item label="产地" prop="originPlace">
-        <el-select 
-          v-model="dataForm.originPlace"
-          style="width: 100%">
-          <el-option
-            v-for="item in originPlaceList"
-            :key="item.value"
-            :label="item.label"
-            :value="item.value">
-          </el-option>
-        </el-select>
-      </el-form-item>
-      <el-form-item label="品种" prop="breed">
-        <el-select 
-          v-model="dataForm.breed"
-          style="width: 100%">
-          <el-option
-            v-for="item in breedList"
-            :key="item.value"
-            :label="item.label"
-            :value="item.value">
-          </el-option>
-        </el-select>
-      </el-form-item>
-      <el-form-item label="养殖状态" prop="outFenceStatus">
-        <el-select 
-          v-model="dataForm.outFenceStatus"
-          style="width: 100%">
-          <el-option
-            v-for="item in outFenceStatus"
-            :key="item.value"
-            :label="item.label"
-            :value="item.value">
-          </el-option>
-        </el-select>
-      </el-form-item>
-      <el-form-item label="父亲" prop="fatherEartag">
-        <el-input v-model="dataForm.fatherEartag"></el-input>
-      </el-form-item>
-      <el-form-item label="母亲" prop="motherEartag">
-        <el-input v-model="dataForm.motherEartag"></el-input>
-      </el-form-item> -->
     </el-form>
     <span slot="footer" class="dialog-footer">
       <el-button size="mini" @click="visible = false">关闭</el-button>
@@ -239,31 +122,6 @@
             { type: 'string' , message: '只允许输入小数', pattern: /^[0-9]{1,2}\.[0-9]{1,}$/ }
           ]
         },
-        // gender: [
-        //   {
-        //     value: '公',
-        //     label: '公'
-        //   },
-        //   {
-        //     value: '母',
-        //     label: '母'
-        //   }
-        // ],
-        // pigstyList: [], // 栋舍List
-        // unitList: [], // 单元List
-        // unitSelectedList: [], // 单元SelectedList
-        // periodList: [], // 栏期List
-        // periodSelectedList: [], // 栏期SelectedList
-        // healthStatus: [
-        //   {
-        //     value: true,
-        //     label: '健康'
-        //   },
-        //   {
-        //     value: false,
-        //     label: '不健康'
-        //   }
-        // ],
         bloodList: [], // 品种list
         originList: [], // 源产地list
         type: [
@@ -280,16 +138,6 @@
             label: '后备母猪'
           }
         ],
-        // outFenceStatus: [
-        //   {
-        //     value: 0,
-        //     label: '育肥'
-        //   },
-        //   {
-        //     value: 1,
-        //     label: '出栏'
-        //   }
-        // ]
       }
     },
     methods: {
@@ -346,78 +194,7 @@
             })
           }
         })
-        // this.$http({
-        //   url: this.$http.adornUrl("/management/pigsty/findAll"),
-        //   method: "get",
-        //   params: this.$http.adornParams({})
-        // }).then(async({ data }) => {
-        //   // 栋舍List
-        //   this.pigstyList = []
-        //   let pigstyList = []
-        //   data.all && (pigstyList = data.all)
-        //   pigstyList.forEach(pigsty => {
-        //     let item = {
-        //       value: pigsty.id,
-        //       label: pigsty.number
-        //     }
-        //     this.pigstyList.push(item)
-        //   })
-        //   // 单元List
-        //   this.unitList = []
-        //   let unitList = []
-        //   let unitR = await this.$http({
-        //     url: this.$http.adornUrl("/management/unit/findAll"),
-        //     method: "get",
-        //     params: this.$http.adornParams({})
-        //   })
-        //   unitR.data.all && (unitList = unitR.data.all)
-        //   unitList.forEach(unit => {
-        //     let item = {
-        //       value: unit.id,
-        //       label: unit.number,
-        //       pigstyId: unit.pigstyId,
-        //       farmId: unit.farmId
-        //     }
-        //     this.unitList.push(item)
-        //   })
-        //   this.unitSelectedList = this.unitList
-        //   // 栏期List
-        //   this.periodList = []
-        //   let periodList = []
-        //   let periodR = await this.$http({
-        //     url: this.$http.adornUrl("/management/period/findAll"),
-        //     method: "get",
-        //     params: this.$http.adornParams({})
-        //   })
-        //   periodR.data.all && (periodList = periodR.data.all)
-        //   periodList.forEach(period => {
-        //     let item = {
-        //       value: period.id,
-        //       label: period.number,
-        //       pigstyId: period.pigstyId
-        //     }
-        //     this.periodList.push(item)
-        //   })
-        //   this.periodSelectedList = this.periodList
-
-
-
-
-          
-        // })
       },
-      // // 根据栋舍选择限制单元和栏期
-      // pigstyChange (val) {
-      //   this.unitSelectedList = this.unitList.filter(item => item.pigstyId === val)
-      //   this.periodSelectedList = this.periodList.filter(item => item.pigstyId === val)
-      // },
-      // // 需要先选择猪舍,才能选择单元或栏期
-      // ifPigsty (val) {
-      //   if (!this.dataForm.pigstyId) {
-      //     this.$message.error('请先选择猪舍')
-      //     this.dataForm[val] = ''
-      //   }
-      // },
       // 表单提交
       dataFormSubmit () {
         this.$refs['dataForm'].validate((valid) => {