Browse Source

2021-06-24,单元和栏期的点中进行修改

East 3 years ago
parent
commit
c89cf737b2

+ 2 - 2
src/views/modules/alarm/meteo.vue

@@ -73,12 +73,12 @@
               align="center"
               label="牧场">
             </el-table-column> -->
-            <el-table-column
+            <!-- <el-table-column
               prop="pigstyName"
               header-align="center"
               align="center"
               label="猪舍">
-            </el-table-column>
+            </el-table-column> -->
             <el-table-column
               header-align="center"
               align="center"

+ 39 - 48
src/views/modules/alarm/temp.vue

@@ -29,9 +29,13 @@
               </el-select>
             </el-form-item>
             <el-form-item style="width: 140px">
-              <el-select placeholder="单元" v-model="form.unitId">
+              <el-select 
+                placeholder="单元" 
+                v-model="form.unitId" 
+                @focus="unitFocus()"
+                ref="unitId">
                 <el-option
-                  v-for="item in unitList"
+                  v-for="item in unitSelectedList"
                   :key="item.id"
                   :label="item.number"
                   :value="item.id">
@@ -84,12 +88,12 @@
             height="578"
             :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
+            <!-- <el-table-column
               prop="nowDate"
               header-align="center"
               align="center"
-              label="当前日期">
-            </el-table-column>
+              label="日期">
+            </el-table-column> -->
             <el-table-column
               prop="earTag"
               header-align="center"
@@ -106,7 +110,7 @@
               prop="unitName"
               header-align="center"
               align="center"
-              label="猪舍">
+              label="单元">
             </el-table-column>
             <el-table-column
               prop="pigstyName"
@@ -188,6 +192,7 @@
         // farmList: [], // 牧场List
         pigstyList: [], // 猪舍List
         unitList: [], // 单元List
+        unitSelectedList: [],
         // pigstySelectedList: [], // 根据牧场限制的猪舍SelectedList
         labelPosition: 'right',
         thresholdTypes: [
@@ -229,12 +234,13 @@
             'page': this.pageIndex,
             'limit': this.pageSize,
             'farmId': parseInt(this.$cookie.get('formFarmId')),
-            'pigstyId': this.form.pigstyId,
+            'pigstyId': this.form.pigstyId || undefined,
+            'unitId': this.form.unitId || undefined,
             'startTime': this.form.time[0] || undefined,
             'endTime': this.form.time[1] || undefined,
             'belongTo': 3,
             'warningType': this.form.warningType || undefined,
-            'earTag': this.form.earTag
+            'earTag': this.form.earTag || undefined
           })
         }).then(async({data}) => {
           if (data && data.code === 0) {
@@ -246,22 +252,6 @@
             this.totalPage = 0
             this.$message.error(data.msg)
           }
-          // // 获取所有牧场
-          // this.farmList = []
-          // let farmList = []
-          // let farmResult = await this.$http({
-          //   url: this.$http.adornUrl("/management/farm/findAll"),
-          //   method: "get",
-          //   params: this.$http.adornParams({})
-          // })
-          // farmResult.data.all && (farmList = farmResult.data.all)
-          // farmList.forEach(farm => {
-          //   let item = {
-          //     label: farm.name,
-          //     value: farm.id
-          //   }
-          //   this.farmList.push(item)
-          // })
           // 猪舍List
           this.pigstyList = []
           let pigstyList = []
@@ -274,8 +264,7 @@
           pigstyList.forEach(pigsty => {
             let item = {
               value: pigsty.id,
-              label: pigsty.number,
-              // farmId: pigsty.farmId
+              label: pigsty.number
             }
             this.pigstyList.push(item)
           })
@@ -287,8 +276,7 @@
             params: this.$http.adornParams({})
           })
           unitR.data.all && (this.unitList = unitR.data.all)
-          // this.pigstySelectedList = this.pigstyList
-          // this.form.farmId = (this.form.farmId || this.farmId) || undefined
+          this.form.pigstyId? this.unitSelectedList = this.unitList.filter(item => item.pigstyId === this.form.pigstyId): this.unitSelectedList = this.unitList
           this.dataListLoading = false
         })
       },
@@ -297,26 +285,19 @@
         this.abnormalStatus = !this.abnormalStatus
         this.getDataList()
       },
-      // // 根据牧场选择限制猪舍
-      // farmChange (val) {
-      //   this.pigstySelectedList = this.pigstyList.filter(item => item.farmId === val)
-      //   if (this.pigsty.farmId === val) {
-      //     return
-      //   }
-      //   this.form.pigstyId = ''
-      // },
-      // // 根据猪舍选择确定牧场
-      // pigstyChange (val) {
-      //   for (let pigsty of this.pigstyList) {
-      //     if (pigsty.value === val) {
-      //       this.form.farmId = pigsty.farmId
-      //       this.pigsty.farmId = pigsty.farmId
-      //       this.pigsty.pigstyId = val
-      //       break
-      //     }
-      //   }
-      //   this.farmChange(this.form.farmId)
-      // },
+      // pigsty的选择
+      pigstyChange () {
+        this.unitSelectedList = this.unitList.filter(item => item.pigstyId === this.form.pigstyId)
+      },
+      // unit的选择
+      unitFocus () {
+        if (!this.form.pigstyId) {
+          this.$message.error('请先选择猪舍')
+          setTimeout(() => {
+            this.$refs.unitId.blur()
+          }, 10)
+        }
+      },
       // 获取起始与结束时间
       timeChange (val) {
         let start = new Date(val[0])
@@ -354,6 +335,16 @@
         this.pageIndex = val
         this.getDataList()
       }
+    },
+    watch: {
+      'form.pigstyId': {
+        handler (newValue, oldValue) {
+          if (oldValue) {
+            this.form.unitId = ''
+            this.unitSelectedList = this.unitList.filter(item => item.pigstyId === newValue)
+          }
+        }
+      }
     }
   }
 </script>

+ 613 - 0
src/views/modules/breed/beartag-dialog.vue

@@ -0,0 +1,613 @@
+<template>
+  <el-dialog
+    :title="'猪只耳标:' + eartag"
+    :visible.sync="visible"
+    :fullscreen="true">
+    <div style="height: 90vh">
+      <div id="line1" style="height: 20%;"></div>
+      <div id="line2" style="height: 20%; margin-top: 30px"></div>
+      <div id="line3" style="height: 20%; margin-top: 30px"></div>
+      <div id="line4" style="height: 20%; margin-top: 30px"></div>
+    </div>
+  </el-dialog>
+</template>
+<script>
+import echarts from 'echarts'
+export default {
+  data() {
+    return {
+      visible: false,
+      eartag: '',
+      data: null
+    }
+  },
+  props: ['time'],
+  methods: {
+    drawChart() {
+      const id = document.getElementById('line1');
+      // 基于准备好的dom,初始化echarts实例
+      const myChart = this.$echarts.init(id);
+      const myChart1 = this.$echarts.init(document.getElementById('line2'));
+      const myChart2 = this.$echarts.init(document.getElementById('line3'));
+      const myChart3 = this.$echarts.init(document.getElementById('line4'));
+      let options; let options1; let options2; let options3
+      // 温度
+      if (this.data.temp.length > 0) {
+        options = {
+          title: {
+            text: '温度',
+            // subtext: `设备ID:${that.subData.sbid},  耳标ID:${that.subData.eartagId},  序列号:${that.subData.serial}`,
+            subtextStyle: {
+              color: '#000',
+            },
+            left: 'center',
+          },
+          legend: {
+            data: ['耳标温度', '环境温度'],
+            x: '20%',
+            y: 'top',
+          },
+          tooltip: {
+            trigger: 'axis',
+            // formatter: '{b} <br/>{a0}: {c0}℃',
+            // position(pt) {
+            //   return [pt[0], '10%'];
+            // },
+          },
+          dataZoom: [{
+            type: 'inside',
+            start: 80,
+            end: 100,
+          }, {
+            start: 0,
+            end: 10,
+            handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
+            handleSize: '80%',
+            handleStyle: {
+              color: '#fff',
+              shadowBlur: 3,
+              shadowColor: 'rgba(0, 0, 0, 0.6)',
+              shadowOffsetX: 2,
+              shadowOffsetY: 2,
+            },
+          }],
+          grid: {
+            left: '2%',
+            right: '4%',
+            bottom: '21%',
+            containLabel: true,
+          },
+          xAxis: {
+            type: 'category',
+            boundaryGap: false,
+            data: this.data.time,
+          },
+          yAxis: {
+            type: 'value',
+            boundaryGap: [0, '100%'],
+            min(value) {
+              return value.min;
+            },
+            axisLabel: {
+              formatter(value) {
+                return value.toFixed(2);
+              },
+            },
+          },
+          series: [
+            {
+              name: '耳标温度',
+              type: 'line',
+              smooth: true,
+              // symbol: 'none',
+              sampling: 'average',
+              itemStyle: {
+                normal: {
+                  color: '#7ED3F4', // 改变折线点的颜色
+                },
+              },
+              data: this.data.temp,
+            },
+            {
+              name: '环境温度',
+              type: 'line',
+              smooth: true,
+              sampling: 'average',
+              itemStyle: {
+                normal: {
+                  color: '#FF7070', // 改变折线点的颜色
+                },
+              },
+              data: this.data.environmenttemp,
+            },
+          ],
+        };
+      } else {
+        options = {
+          title: {
+            text: '暂无数据',
+            x: 'center',
+            y: 'center',
+            textStyle: {
+              color: '#000000',
+              fontWeight: 'normal',
+              fontSize: 12,
+            },
+          },
+          grid: {
+            left: '3%',
+            right: '4%',
+            bottom: '3%',
+            containLabel: true,
+          },
+          xAxis: {
+            type: 'category',
+            boundaryGap: false,
+            data: [],
+            axisLabel: {
+              show: true,
+              textStyle: {
+                color: '#000000', // 更改坐标轴文字颜色
+              },
+            },
+          },
+          yAxis: {
+            type: 'value',
+            axisLabel: {
+              show: true,
+              textStyle: {
+                color: '#000000', // 更改坐标轴文字颜色
+              },
+            },
+          },
+          series: [
+            {
+              name: '湿度',
+              type: 'line',
+              itemStyle: {
+                normal: {
+                  color: '#275F82', // 改变折线点的颜色
+                  lineStyle: {
+                    color: 'rgb(146 200 175)', // 改变折线颜色
+                  },
+                },
+              },
+              data: [],
+            },
+          ],
+        };
+      }
+      // 耳标电量
+      if (this.data.electric.length > 0) {
+        options1 = {
+          title: {
+            text: '耳标电量',
+            // subtext: `设备ID:${this.subData.sbid},  耳标ID:${that.subData.eartagId},  序列号:${that.subData.serial}`,
+            subtextStyle: {
+              color: '#000',
+            },
+            left: 'center',
+          },
+          tooltip: {
+            trigger: 'axis',
+            formatter: '{b} <br/>{a0}: {c0}%',
+            position(pt) {
+              return [pt[0], '10%'];
+            },
+          },
+          dataZoom: [{
+            type: 'inside',
+            start: 90,
+            end: 100,
+          }, {
+            start: 0,
+            end: 10,
+            handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
+            handleSize: '80%',
+            handleStyle: {
+              color: '#fff',
+              shadowBlur: 3,
+              shadowColor: 'rgba(0, 0, 0, 0.6)',
+              shadowOffsetX: 2,
+              shadowOffsetY: 2,
+            },
+          }],
+          grid: {
+            left: '3%',
+            right: '4%',
+            bottom: '21%',
+            containLabel: true,
+          },
+          xAxis: {
+            type: 'category',
+            boundaryGap: false,
+            data: this.data.time,
+          },
+          yAxis: {
+            type: 'value',
+            boundaryGap: [0, '100%'],
+            min(value) {
+              return value.min;
+            },
+          },
+          series: [
+            {
+              name: '电量',
+              type: 'line',
+              smooth: true,
+              // symbol: 'none',
+              sampling: 'average',
+              itemStyle: {
+                normal: {
+                  color: '#275F82', // 改变折线点的颜色
+                },
+              },
+              data: this.data.electric,
+            },
+          ],
+        };
+      } else {
+        options1 = {
+          title: {
+            text: '暂无数据',
+            x: 'center',
+            y: 'center',
+            textStyle: {
+              color: '#000000',
+              fontWeight: 'normal',
+              fontSize: 12,
+            },
+          },
+          grid: {
+            left: '3%',
+            right: '4%',
+            bottom: '3%',
+            containLabel: true,
+          },
+          xAxis: {
+            type: 'category',
+            boundaryGap: false,
+            data: [],
+            axisLabel: {
+              show: true,
+              textStyle: {
+                color: '#000000', // 更改坐标轴文字颜色
+              },
+            },
+          },
+          yAxis: {
+            type: 'value',
+            axisLabel: {
+              show: true,
+              textStyle: {
+                color: '#000000', // 更改坐标轴文字颜色
+              },
+            },
+          },
+          series: [
+            {
+              name: '湿度',
+              type: 'line',
+              itemStyle: {
+                normal: {
+                  color: '#275F82', // 改变折线点的颜色
+                  lineStyle: {
+                    color: 'rgb(146 200 175)', // 改变折线颜色
+                  },
+                },
+              },
+              data: [],
+            },
+          ],
+        };
+      }
+      // 运动量
+      if (this.data.sports.length > 0) {
+        // 运动量
+        options2 = {
+          title: {
+            text: '运动量',
+            // subtext: `设备ID:${that.subData.sbid},  耳标ID:${that.subData.eartagId},  序列号:${that.subData.serial}`,
+            subtextStyle: {
+              color: '#000',
+            },
+            left: 'center',
+          },
+          tooltip: {
+            trigger: 'axis',
+            formatter: '{b} <br/>{a0}: {c0}次',
+            position(pt) {
+              return [pt[0], '10%'];
+            },
+          },
+          dataZoom: [{
+            type: 'inside',
+            start: 90,
+            end: 100,
+          }, {
+            start: 0,
+            end: 10,
+            handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
+            handleSize: '80%',
+            handleStyle: {
+              color: '#fff',
+              shadowBlur: 3,
+              shadowColor: 'rgba(0, 0, 0, 0.6)',
+              shadowOffsetX: 2,
+              shadowOffsetY: 2,
+            },
+          }],
+          grid: {
+            left: '3%',
+            right: '4%',
+            bottom: '21%',
+            containLabel: true,
+          },
+          xAxis: {
+            type: 'category',
+            boundaryGap: false,
+            data: this.data.time,
+
+          },
+          yAxis: {
+            type: 'value',
+            boundaryGap: [0, '100%'],
+            min(value) {
+              return value.min;
+            },
+          },
+          series: [
+            {
+              name: '运动量',
+              type: 'line',
+              smooth: true,
+              // symbol: 'none',
+              sampling: 'average',
+              itemStyle: {
+                normal: {
+                  color: '#275F82', // 改变折线点的颜色
+                },
+              },
+              data: this.data.sports,
+            },
+          ],
+        };
+      } else {
+        options2 = {
+          title: {
+            text: '暂无数据',
+            x: 'center',
+            y: 'center',
+            textStyle: {
+              color: '#000000',
+              fontWeight: 'normal',
+              fontSize: 12,
+            },
+          },
+          grid: {
+            left: '3%',
+            right: '4%',
+            bottom: '3%',
+            containLabel: true,
+          },
+          xAxis: {
+            type: 'category',
+            boundaryGap: false,
+            data: [],
+            axisLabel: {
+              show: true,
+              textStyle: {
+                color: '#000000', // 更改坐标轴文字颜色
+              },
+            },
+          },
+          yAxis: {
+            type: 'value',
+            axisLabel: {
+              show: true,
+              textStyle: {
+                color: '#000000', // 更改坐标轴文字颜色
+              },
+            },
+          },
+          series: [
+            {
+              name: '湿度',
+              type: 'line',
+              itemStyle: {
+                normal: {
+                  color: '#275F82', // 改变折线点的颜色
+                  lineStyle: {
+                    color: 'rgb(146 200 175)', // 改变折线颜色
+                  },
+                },
+              },
+              data: [],
+            },
+          ],
+        };
+      }
+      // 睡眠
+      if (this.data.temp.length > 0) {
+        options3 = {
+          title: {
+            text: '睡眠',
+            // subtext: `设备ID:${that.subData.sbid},  耳标ID:${that.subData.eartagId},  序列号:${that.subData.serial}`,
+            subtextStyle: {
+              color: '#000',
+            },
+            left: 'center',
+          },
+          // legend: {
+          //   data: ['耳标温度', '环境温度'],
+          //   x: '20%',
+          //   y: 'top',
+          // },
+          tooltip: {
+            trigger: 'axis',
+            // formatter: '{b} <br/>{a0}: {c0}℃',
+            // position(pt) {
+            //   return [pt[0], '10%'];
+            // },
+          },
+          dataZoom: [{
+            type: 'inside',
+            start: 80,
+            end: 100,
+          }, {
+            start: 0,
+            end: 10,
+            handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
+            handleSize: '80%',
+            handleStyle: {
+              color: '#fff',
+              shadowBlur: 3,
+              shadowColor: 'rgba(0, 0, 0, 0.6)',
+              shadowOffsetX: 2,
+              shadowOffsetY: 2,
+            },
+          }],
+          grid: {
+            left: '2%',
+            right: '4%',
+            bottom: '21%',
+            containLabel: true,
+          },
+          xAxis: {
+            type: 'category',
+            boundaryGap: false,
+            data: this.data.time,
+          },
+          yAxis: {
+            type: 'value',
+            boundaryGap: [0, '100%'],
+            min(value) {
+              return value.min;
+            },
+            axisLabel: {
+              formatter(value) {
+                return value.toFixed(2);
+              },
+            },
+          },
+          series: [
+            {
+              name: '是否睡眠',
+              type: 'line',
+              smooth: true,
+              // symbol: 'none',
+              sampling: 'average',
+              itemStyle: {
+                normal: {
+                  color: '#7ED3F4', // 改变折线点的颜色
+                },
+              },
+              data: this.data.sleeptime,
+            },
+            // {
+            //   name: '环境温度',
+            //   type: 'line',
+            //   smooth: true,
+            //   sampling: 'average',
+            //   itemStyle: {
+            //     normal: {
+            //       color: '#FF7070', // 改变折线点的颜色
+            //     },
+            //   },
+            //   data: this.data.environmenttemp,
+            // },
+          ],
+        };
+      } else {
+        options3 = {
+          title: {
+            text: '暂无数据',
+            x: 'center',
+            y: 'center',
+            textStyle: {
+              color: '#000000',
+              fontWeight: 'normal',
+              fontSize: 12,
+            },
+          },
+          grid: {
+            left: '3%',
+            right: '4%',
+            bottom: '3%',
+            containLabel: true,
+          },
+          xAxis: {
+            type: 'category',
+            boundaryGap: false,
+            data: [],
+            axisLabel: {
+              show: true,
+              textStyle: {
+                color: '#000000', // 更改坐标轴文字颜色
+              },
+            },
+          },
+          yAxis: {
+            type: 'value',
+            axisLabel: {
+              show: true,
+              textStyle: {
+                color: '#000000', // 更改坐标轴文字颜色
+              },
+            },
+          },
+          series: [
+            {
+              name: '湿度',
+              type: 'line',
+              itemStyle: {
+                normal: {
+                  color: '#275F82', // 改变折线点的颜色
+                  lineStyle: {
+                    color: 'rgb(146 200 175)', // 改变折线颜色
+                  },
+                },
+              },
+              data: [],
+            },
+          ],
+        };
+      }
+
+      myChart.setOption(options);
+      myChart1.setOption(options1);
+      myChart2.setOption(options2);
+      myChart3.setOption(options3);
+    },
+    init (eartag) {
+      console.log(this.time);
+      this.visible = true
+      const load = this.$loading({
+        lock: true,
+        text: '加载中...',
+        spinner: 'el-icon-loading',
+        background: 'rgba(0, 0, 0, 0.7)'
+      })
+      this.eartag = eartag
+      this.$http({
+        url: this.$http.adornUrl('/management/eartagdate/searchDateByCondition'),
+        method: 'get',
+        params: this.$http.adornParams({
+          'eartag': this.eartag,
+          'startTime': this.time[0],
+          'endTime': this.time[1]
+        }, false)
+      }).then(({data}) => {
+        if (data && data.code === 0) {
+          this.data = data.page
+          this.drawChart()
+          load.close()
+        }
+      })
+    }
+  },
+}
+</script>
+<style scoped>
+
+</style>

+ 548 - 0
src/views/modules/breed/beartag.vue

@@ -0,0 +1,548 @@
+<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 breedList"
+                  :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" 
+                ref="unit"
+                @focus="selectFocus('unit')">
+                <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" 
+                ref="period"
+                @focus="selectFocus('period')">
+                <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>
+      <!-- 猪只基本信息表格 -->
+      <el-main>
+        <div class="rect rect-table">
+          <el-form inline size="mini">
+            <el-form-item label="耳标信息的时间区间">
+              <el-date-picker
+                v-model="time"
+                type="datetimerange"
+                align="right"
+                start-placeholder="开始时间"
+                end-placeholder="结束时间"
+                :default-time="['08:00:00', '16:00:00']"
+                @change="timeChange"
+                value-format="yyyy-MM-dd HH:mm:ss">
+              </el-date-picker>
+            </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)"
+                  @click="eartagDialogHandle(scope.row.eartag)">
+                  查看耳标信息
+                </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>
+        </div>
+      </el-main>
+
+      <beartag-dialog v-if="dialogVisible" ref="eartagDialog" :time="time"></beartag-dialog>
+      
+      
+    </el-container>
+  </div>
+</template>
+
+<script>
+  import beartagDialog from './beartag-dialog.vue'
+  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: '母'
+          }
+        ],
+        breedList: [],
+        healthStatus: [
+          {
+            value: 1,
+            label: '健康'
+          },
+          {
+            value: 0,
+            label: '不健康'
+          }
+        ],
+        outFenceStatus: [
+          {
+            value: 0,
+            label: '育肥'
+          },
+          {
+            value: 1,
+            label: '出栏'
+          }
+        ],
+        periodList: [], // 所有栏期
+        periodSelectedList: [], // 根据栋舍限制的栏期
+        pigstyList: [], // 所有栋舍
+        unitList: [], // 所有单元
+        unitSelectedList: [], // 根据栋舍限制的单元
+        labelPosition: 'right',
+        dialogVisible: false, // 控制 耳标信息dialog 的显示
+        time: [] // 查看耳标信息时要传入的值
+      }
+    },
+    components: {
+      beartagDialog
+    },
+    activated () {
+      this.getDataList()
+    },
+    methods: {
+      // 获取数据列表
+      getDataList (val) {
+        this.dataListLoading = true
+        
+        // 对 新增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,
+            '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
+          this.breedList = []
+          let breedList = []
+          let breedR = await this.$http({
+            url: this.$http.adornUrl("/management/basebloodline/findAll"),
+            method: "get",
+            params: this.$http.adornParams({})
+          })
+          breedR.data.all && (breedList = breedR.data.all)
+          breedList.forEach(breed => {
+            let item = {
+              value: breed.name,
+              label: breed.name
+            }
+            this.breedList.push(item)
+          })
+          // 获取猪只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)
+      },
+      // 点击 单元or栏期的选择框
+      selectFocus (val) {
+        if (!this.form.pigstyId) {
+          this.$message.error('请先选择猪舍')
+          this.form[val + 'Id'] = ''
+          setTimeout(() => {
+            this.$refs[val].blur()
+          }, 10)
+        }
+      },
+      // 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
+      },
+      timeChange (val) {
+        let start = new Date(val[0])
+        let end = new Date(val[1])
+        let now = new Date()
+        if (start > now || end > now) {
+          this.time = []
+          this.$message.error('请勿选择超出现在的时刻')
+        }
+      },
+      // 点击 “查看耳标信息” 按钮
+      eartagDialogHandle (eartag) {
+        if (this.time.length < 1) {
+          this.$message.error('请先选择耳标信息的时间区间')
+          return
+        }
+        this.dialogVisible = true
+        this.$nextTick(() => {
+          this.$refs.eartagDialog.init(eartag)
+        })
+      }
+    },
+    watch: {
+      'form.pigstyId': {
+        handler(newValue, oldValue) {
+          if (oldValue) {
+            this.form.unitId = ''
+            this.form.periodId = ''
+            this.unitSelectedList = this.unitList.filter(item => item.pigstyId === newValue)
+            this.periodSelectedList = this.periodList.filter(item => item.pigstyId === newValue)
+          }
+        }
+      }
+    }
+  }
+</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>

+ 12 - 109
src/views/modules/breed/btransfer-update.vue

@@ -47,105 +47,6 @@
           </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="birthday">
-        <el-date-picker
-          v-model="dataForm.birthday"
-          type="date"
-          value-format="yyyy-MM-dd"
-          placeholder="请选择出生日期"
-          @change="changeBirth"
-          style="width: 100%">
-        </el-date-picker>
-      </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>
@@ -215,16 +116,16 @@
             label: '不健康'
           }
         ],
-        breedList: [
-          {
-            value: 1,
-            label: '杜巴嘉'
-          },
-          {
-            value: 2,
-            label: '长白'
-          }
-        ], // 品种List
+        // breedList: [
+        //   {
+        //     value: 1,
+        //     label: '杜巴嘉'
+        //   },
+        //   {
+        //     value: 2,
+        //     label: '长白'
+        //   }
+        // ], // 品种List
         originPlaceList: [], // 产地List
         outFenceStatus: [
           {
@@ -411,6 +312,8 @@
           if (oldValue) {
             this.dataForm.unitId = ''
             this.dataForm.periodId = ''
+            this.unitSelectedList = this.unitList.filter(item => item.pigstyId === newValue)
+            this.periodSelectedList = this.periodList.filter(item => item.pigstyId === newValue)
           }
         }
       }

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

@@ -288,6 +288,7 @@
         handler (newValue, oldValue) {
           if (oldValue) {
             this.form.oldUnitId = ''
+            this.oldUnitSelectedList = this.unitList.filter(item => item.pigstyId === newValue)
           }
         }
       },
@@ -295,6 +296,7 @@
         handler (newValue, oldValue) {
           if (oldValue) {
             this.form.newUnitId = ''
+            this.newUnitSelectedList = this.unitList.filter(item => item.pigstyId === newValue)
           }
         }
       }

+ 17 - 10
src/views/modules/pigbasic/pbbasic.vue

@@ -63,7 +63,11 @@
               </el-select>
             </el-form-item>
             <el-form-item style="width: 140px">
-              <el-select placeholder="单元" style="width: 140px" v-model="searchForm.unitId" @change="ifPigsty('unitId')">
+              <el-select 
+                placeholder="单元" 
+                style="width: 140px" 
+                v-model="searchForm.unitId" 
+                @focus="selectFocus('unit')">
                 <el-option
                   v-for="item in unitSelectedList"
                   :key="item.label"
@@ -74,7 +78,11 @@
             </el-form-item>
             <el-form-item>
             <el-form-item style="width: 140px">
-              <el-select placeholder="栏期" style="width: 140px" v-model="searchForm.periodId" @change="ifPigsty('periodId')">
+              <el-select 
+                placeholder="栏期" 
+                style="width: 140px" 
+                v-model="searchForm.periodId" 
+                @focus="selectFocus('period')">
                 <el-option
                   v-for="item in periodSelectedList"
                   :key="item.label"
@@ -631,15 +639,14 @@ export default {
       this.unitSelectedList = this.unitList.filter(item => item.pigstyId === val)
       this.periodSelectedList = this.periodList.filter(item => item.pigstyId === val)
     },
-    // 需要先选择猪舍,才能选择单元或栏期
-    ifPigsty (val) {
-      if (!this.searchForm.pigstyId && this.searchForm[val]) {
-        this.$message.error('请先选择猪舍')
-        this.searchForm[val] = ''
-      }
-      if (!this.form.pigstyId && this.form[val]) {
+    // 点击 单元or栏期的选择框
+    selectFocus (val) {
+      if (!this.form.pigstyId) {
         this.$message.error('请先选择猪舍')
-        this.form[val] = ''
+        this.form[val + 'Id'] = ''
+        setTimeout(() => {
+          this.$refs[val].blur()
+        }, 10)
       }
     },
     // 每页数

+ 19 - 11
src/views/modules/pigbasic/pbentry.vue

@@ -21,7 +21,7 @@
             <el-form-item style="width: 140px">
               <el-select placeholder="品种" v-model="form.breed">
                 <el-option
-                  v-for="item in breed"
+                  v-for="item in breedList"
                   :key="item.value"
                   :label="item.label"
                   :value="item.value">
@@ -282,16 +282,7 @@
             label: '母'
           }
         ],
-        breed: [
-          {
-            value: 1,
-            label: '杜巴嘉'
-          },
-          {
-            value: 2,
-            label: '长白'
-          }
-        ],
+        breedList: [],
         healthStatus: [
           {
             value: 1,
@@ -416,8 +407,25 @@
             }
             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
+          this.breedList = []
+          let breedList = []
+          let breedR = await this.$http({
+            url: this.$http.adornUrl("/management/basebloodline/findAll"),
+            method: "get",
+            params: this.$http.adornParams({})
+          })
+          breedR.data.all && (breedList = breedR.data.all)
+          breedList.forEach(breed => {
+            let item = {
+              value: breed.name,
+              label: breed.name
+            }
+            this.breedList.push(item)
+          })
           // 获取猪只List
           if (data && data.code === 0) {
             this.dataList = data.page.list

+ 18 - 11
src/views/modules/pigbasic/pbexit.vue

@@ -21,7 +21,7 @@
             <el-form-item style="width: 140px">
               <el-select placeholder="品种" v-model="form.breed">
                 <el-option
-                  v-for="item in breed"
+                  v-for="item in breedList"
                   :key="item.value"
                   :label="item.label"
                   :value="item.value">
@@ -282,16 +282,7 @@
             label: '母'
           }
         ],
-        breed: [
-          {
-            value: 1,
-            label: '杜巴嘉'
-          },
-          {
-            value: 2,
-            label: '长白'
-          }
-        ],
+        breedList: [],
         healthStatus: [
           {
             value: 1,
@@ -418,6 +409,22 @@
           })
           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
+          this.breedList = []
+          let breedList = []
+          let breedR = await this.$http({
+            url: this.$http.adornUrl("/management/basebloodline/findAll"),
+            method: "get",
+            params: this.$http.adornParams({})
+          })
+          breedR.data.all && (breedList = breedR.data.all)
+          breedList.forEach(breed => {
+            let item = {
+              value: breed.name,
+              label: breed.name
+            }
+            this.breedList.push(item)
+          })
           // 获取猪只List
           if (data && data.code === 0) {
             this.dataList = data.page.list

+ 48 - 57
src/views/modules/pigbasic/pbped-details.vue

@@ -252,7 +252,7 @@
           healthStatus: true,
           weight: '',
           originPlace: '',
-          breed: '',
+          // breed: '',
           outFenceStatus: 0,
           motherEartag: '',
           fatherEartag: ''
@@ -322,16 +322,7 @@
             label: '不健康'
           }
         ],
-        breedList: [
-          {
-            value: 1,
-            label: '杜巴嘉'
-          },
-          {
-            value: 2,
-            label: '长白'
-          }
-        ], // 品种List
+        // breedList: [], // 品种List
         originPlaceList: [], // 产地List
         outFenceStatus: [
           {
@@ -463,52 +454,52 @@
           
         // })
       },
-      // 表单提交
-      dataFormSubmit () {
-        this.$refs['dataForm'].validate((valid) => {
-          console.log(valid);
-          if (valid) {
-            this.$http({
-              url: this.$http.adornUrl(`${!this.dataForm.id ?'/management/yearpigbase/batchLairage': '/management/yearpigbase/update'}`),
-              method: 'post',
-              data: this.$http.adornData({
-                'id': this.dataForm.id || undefined,
-                'eartag': this.dataForm.eartag,
-                'pigstyId': this.dataForm.pigstyId,
-                'unitId': this.dataForm.unitId,
-                'periodId': this.dataForm.periodId,
-                'sex': this.dataForm.sex,
-                'birthday': this.dataForm.birthday,
-                '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
-              })
-            }).then(({data}) => {
-              if (data && data.code === 0) {
-                this.visible = false
-                this.$emit('refreshDataList')
-                this.$message({
-                  message: '操作成功',
-                  type: 'success',
-                  duration: 1500,
-                  // onClose: () => {
-                  //   this.visible = false
-                  //   this.$emit('refreshDataList')
-                  // }
-                })
-                // this.resetForm()
-                this.visible = false
-              } else {
-                this.$message.error(data.msg)
-              }
-            })
-          }
-        })
-      },
+      // // 表单提交
+      // dataFormSubmit () {
+      //   this.$refs['dataForm'].validate((valid) => {
+      //     console.log(valid);
+      //     if (valid) {
+      //       this.$http({
+      //         url: this.$http.adornUrl(`${!this.dataForm.id ?'/management/yearpigbase/batchLairage': '/management/yearpigbase/update'}`),
+      //         method: 'post',
+      //         data: this.$http.adornData({
+      //           'id': this.dataForm.id || undefined,
+      //           'eartag': this.dataForm.eartag,
+      //           'pigstyId': this.dataForm.pigstyId,
+      //           'unitId': this.dataForm.unitId,
+      //           'periodId': this.dataForm.periodId,
+      //           'sex': this.dataForm.sex,
+      //           'birthday': this.dataForm.birthday,
+      //           '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
+      //         })
+      //       }).then(({data}) => {
+      //         if (data && data.code === 0) {
+      //           this.visible = false
+      //           this.$emit('refreshDataList')
+      //           this.$message({
+      //             message: '操作成功',
+      //             type: 'success',
+      //             duration: 1500,
+      //             // onClose: () => {
+      //             //   this.visible = false
+      //             //   this.$emit('refreshDataList')
+      //             // }
+      //           })
+      //           // this.resetForm()
+      //           this.visible = false
+      //         } else {
+      //           this.$message.error(data.msg)
+      //         }
+      //       })
+      //     }
+      //   })
+      // },
       // 获取出生日期
       changeBirth(val) {
         let birth = new Date(val);

+ 18 - 12
src/views/modules/pigbasic/pbpedigree.vue

@@ -21,7 +21,7 @@
             <el-form-item style="width: 140px">
               <el-select placeholder="品种" v-model="form.breed">
                 <el-option
-                  v-for="item in breed"
+                  v-for="item in breedList"
                   :key="item.value"
                   :label="item.label"
                   :value="item.value">
@@ -278,16 +278,7 @@
             label: '母'
           }
         ],
-        breed: [
-          {
-            value: 1,
-            label: '杜巴嘉'
-          },
-          {
-            value: 2,
-            label: '长白'
-          }
-        ],
+        breedList: [],
         healthStatus: [
           {
             value: true,
@@ -401,9 +392,24 @@
             }
             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
+          this.breedList = []
+          let breedList = []
+          let breedR = await this.$http({
+            url: this.$http.adornUrl("/management/basebloodline/findAll"),
+            method: "get",
+            params: this.$http.adornParams({})
+          })
+          breedR.data.all && (breedList = breedR.data.all)
+          breedList.forEach(breed => {
+            let item = {
+              value: breed.name,
+              label: breed.name
+            }
+            this.breedList.push(item)
+          })
           // 获取猪只List
           if (data && data.code === 0) {
             this.dataList = data.page.list