Bladeren bron

2021.06.28,我把选择框的UI都改完了!!!

East 4 jaren geleden
bovenliggende
commit
014af745b6

BIN
src/assets/img/pig.png


+ 3 - 1
src/views/main-navbar.vue

@@ -59,7 +59,9 @@
         <el-menu-item class="site-navbar__avatar" index="3">
           <el-dropdown :show-timeout="0" placement="bottom">
             <span class="el-dropdown-link">
-              <img src="~@/assets/img/avatar.png" :alt="userName">{{ userName }}
+              <!-- <img src="~@/assets/img/avatar.png" :alt="userName">{{ userName }} -->
+              <img src="~@/assets/img/pig.png" :alt="userName" style="height: 40px">
+              {{ userName }}
             </span>
             <el-dropdown-menu slot="dropdown">
               <el-dropdown-item @click.native="updatePasswordHandle()">修改密码</el-dropdown-item>

+ 48 - 29
src/views/modules/basic/period.vue

@@ -12,8 +12,7 @@
               <el-select 
                 v-model="dataForm.pigstyId" 
                 placeholder="猪舍" 
-                style="width: 100%"
-                @change="pigstyChange">
+                style="width: 100%">
                 <el-option
                   v-for="item in phSelectedList"
                   :key="item.id"
@@ -27,7 +26,8 @@
                 v-model="dataForm.unitId" 
                 placeholder="单元" 
                 style="width: 100%"
-                @change="ifPigsty">
+                ref="unit"
+                @focus="selectFocus('unit')">
                 <el-option
                   v-for="item in unitSelectedList"
                   :key="item.id"
@@ -63,7 +63,7 @@
                 新 增
               </el-button>
             </el-form-item>
-            <!-- <el-form-item>
+            <el-form-item>
               <el-button 
                 icon="el-icon-delete" 
                 type="danger" 
@@ -71,7 +71,7 @@
                 :disabled="selectionDataList.length <= 0">
                 删 除
               </el-button>
-            </el-form-item> -->
+            </el-form-item>
           </el-form>
           <el-table
             height="540"
@@ -168,8 +168,7 @@
                 <el-select 
                   v-model="form.pigstyId" 
                   placeholder="请选择所属猪舍" 
-                  style="width: 100%"
-                  @change="pigstyChange">
+                  style="width: 100%">
                   <el-option
                     v-for="item in phSelectedList"
                     :key="item.id"
@@ -183,7 +182,8 @@
                   v-model="form.unitId" 
                   placeholder="单元" 
                   style="width: 100%"
-                  @change="ifUnit">
+                  ref="unitDialog"
+                  @focus="selectFocus()">
                   <el-option
                     v-for="item in unitSelectedList"
                     :key="item.id"
@@ -297,6 +297,17 @@ export default {
         this.dataListLoading = false
       })
     },
+    // 点击 单元or栏期的选择框
+    selectFocus (val) {
+      let form = val === 'unit'? 'dataForm': 'form'
+      let unit = val === 'unit'? 'unit': 'unitDialog'
+      if (!this[form].pigstyId) {
+        this.$message.error('请先选择猪舍')
+        setTimeout(() => {
+          this.$refs[unit].blur()
+        }, 10)
+      }
+    },
     // 清空查询内容
     clearAll () {
       this.dataForm.key = ''
@@ -314,26 +325,26 @@ export default {
       this.pageIndex = val
       this.getDataList()
     },
-    // 根据栋舍选择限制栏期
-    pigstyChange (val) {
-      this.unitSelectedList = this.unitList.filter(item => item.pigstyId === val)
-      console.log(this.unitSelectedList);
-      // this.periodSelectedList = this.periodList.filter(item => item.pigstyId === val)
-    },
-    // 需要先选择猪舍,才能选择单元或栏期
-    ifPigsty () {
-      if (!this.dataForm.pigstyId) {
-        this.$message.error('请先选择猪舍')
-        this.dataForm.unitId = ''
-      }
-    },
-    // 新增时,需要先选择猪舍,才能选择单元或栏期
-    ifUnit() {
-      if (!this.form.pigstyId) {
-        this.$message.error('请先选择猪舍')
-        this.form.unitId = ''
-      }
-    },
+    // // 根据栋舍选择限制栏期
+    // pigstyChange (val) {
+    //   this.unitSelectedList = this.unitList.filter(item => item.pigstyId === val)
+    //   console.log(this.unitSelectedList);
+    //   // this.periodSelectedList = this.periodList.filter(item => item.pigstyId === val)
+    // },
+    // // 需要先选择猪舍,才能选择单元或栏期
+    // ifPigsty () {
+    //   if (!this.dataForm.pigstyId) {
+    //     this.$message.error('请先选择猪舍')
+    //     this.dataForm.unitId = ''
+    //   }
+    // },
+    // // 新增时,需要先选择猪舍,才能选择单元或栏期
+    // ifUnit() {
+    //   if (!this.form.pigstyId) {
+    //     this.$message.error('请先选择猪舍')
+    //     this.form.unitId = ''
+    //   }
+    // },
     // // 获取到了牧场 → 限制猪舍
     // getPasture (val) {
     //   this.phSelectedList = []
@@ -607,8 +618,16 @@ export default {
       handler(newValue, oldValue) {
         if (oldValue) {
           this.dataForm.unitId = ''
-          this.dataForm.periodId = ''
         }
+        this.unitSelectedList = this.unitList.filter(item => item.pigstyId === newValue)
+      }
+    },
+    'form.pigstyId': {
+      handler (newValue, oldValue) {
+        if (oldValue) {
+          this.form.unitId = ''
+        }
+        this.unitSelectedList = this.unitList.filter(item => item.pigstyId === newValue)
       }
     }
   }

+ 50 - 38
src/views/modules/basic/unit.vue

@@ -12,8 +12,7 @@
               <el-select 
                 v-model="dataForm.pigstyId" 
                 placeholder="猪舍" 
-                style="width: 100%"
-                @change="pigstyChange">
+                style="width: 100%">
                 <el-option
                   v-for="item in pigstyList"
                   :key="item.id"
@@ -27,7 +26,8 @@
                 v-model="dataForm.periodId" 
                 placeholder="栏期" 
                 style="width: 100%"
-                @change="periodChange">
+                ref="period"
+                @focus="selectFocus('period')">
                 <el-option
                   v-for="item in periodSelectedList"
                   :key="item.id"
@@ -170,7 +170,10 @@
                 </el-select>
               </el-form-item> -->
               <el-form-item label="所属猪舍" prop="pigstyId">
-                <el-select v-model="form.pigstyId" placeholder="请选择所属猪舍" @change="pigstyChange" style="width: 100%">
+                <el-select 
+                  v-model="form.pigstyId" 
+                  placeholder="请选择所属猪舍" 
+                  style="width: 100%">
                   <el-option
                     v-for="item in pigstyList"
                     :key="item.id"
@@ -296,7 +299,7 @@ export default {
           params: this.$http.adornParams({})
         })
         periodResult.data.all && (this.periodList = periodResult.data.all)
-        this.dataForm.pigstyId? this.periodSelectedList = this.periodList.filter(item => item.pigstyId === this.dataForm.pigstyId): this.periodSelectedList = this.periodList
+        this.periodSelectedList = this.dataForm.pigstyId? this.periodList.filter(item => item.pigstyId === this.dataForm.pigstyId): this.periodList
 
         if (data && data.code === 0) {
           this.dataList = data.page.list
@@ -320,7 +323,6 @@ export default {
           //   }
           // });
           
-          console.log(this.dataList);
         } else {
           this.dataList = []
           this.totalPage = 0
@@ -328,6 +330,16 @@ export default {
         this.dataListLoading = false
       })
     },
+    // 点击 单元or栏期的选择框
+    selectFocus (val) {
+      if (!this.dataForm.pigstyId) {
+        this.$message.error('请先选择猪舍')
+        this.dataForm[val + 'Id'] = ''
+        setTimeout(() => {
+          this.$refs[val].blur()
+        }, 10)
+      }
+    },
     // 清空查询内容
     clearAll () {
       this.dataForm.key = ''
@@ -345,18 +357,18 @@ export default {
       this.pageIndex = val
       this.getDataList()
     },
-    // 选择猪舍 → 限制栏期
-    pigstyChange (val) {
-      this.periodSelectedList = this.periodList.filter(item => item.pigstyId === val)
-    },
-    // 栏期选择的限制
-    periodChange (val) {
-      if (!this.dataForm.pigstyId) {
-        this.$message.error('请先选择猪舍')
-        this.dataForm.periodId = ''
-      }
-      console.log(val);
-    },
+    // // 选择猪舍 → 限制栏期
+    // pigstyChange (val) {
+    //   this.periodSelectedList = this.periodList.filter(item => item.pigstyId === val)
+    // },
+    // // 栏期选择的限制
+    // periodChange (val) {
+    //   if (!this.dataForm.pigstyId) {
+    //     this.$message.error('请先选择猪舍')
+    //     this.dataForm.periodId = ''
+    //   }
+    //   console.log(val);
+    // },
     // // 获取到了牧场 → 限制猪舍
     // getPasture (val) {
     //   this.phSelectedList = []
@@ -404,26 +416,27 @@ export default {
           for (let key of Object.keys(this.form)) {
             this.form[key] = row[key]
           }
+          console.log(this.form);
         })
       }
-      // 解决猪舍、牧场已删除,但该页面仍不变问题
-      this.$http({
-        url: this.$http.adornUrl("/management/pigsty/findAll"),
-        method: "get",
-        params: this.$http.adornParams({})
-      }).then(async ({ data }) => {
-        if (data && data.code === 0) {
-          this.pigstyList = data.all
-          // 获取猪舍
-          let periodResult = await this.$http({
-            url: this.$http.adornUrl('/management/period/findAll'),
-            method: 'get',
-            params: this.$http.adornParams({})
-          })
-          periodResult.data.all && (this.periodList = periodResult.data.all)
-          this.periodSelectedList = this.periodList.filter(item => item.pigstyId === row.pigstyId)
-        }
-      })
+      // // 解决猪舍、牧场已删除,但该页面仍不变问题
+      // this.$http({
+      //   url: this.$http.adornUrl("/management/pigsty/findAll"),
+      //   method: "get",
+      //   params: this.$http.adornParams({})
+      // }).then(async ({ data }) => {
+      //   if (data && data.code === 0) {
+      //     this.pigstyList = data.all
+      //     // 获取猪舍
+      //     let periodResult = await this.$http({
+      //       url: this.$http.adornUrl('/management/period/findAll'),
+      //       method: 'get',
+      //       params: this.$http.adornParams({})
+      //     })
+      //     periodResult.data.all && (this.periodList = periodResult.data.all)
+      //     this.periodSelectedList = this.periodList.filter(item => item.pigstyId === row.pigstyId)
+      //   }
+      // })
     },
     // 选择n个牧场
     selectionChangeHandle (val) {
@@ -451,7 +464,6 @@ export default {
           method: 'post',
           data: this.$http.adornData(this.selectionDataList, false)
         }).then(result => {
-          console.log(result);
           if (result.data.code === 0) {
             this.resetForm()
             this.$message({
@@ -593,7 +605,6 @@ export default {
     // 校验输入是否完整
     validComplete (val) {
       val && (delete this.form.id)
-      console.log(this.form);
       for (let i in this.form) {
         if (!this.form[i].toString()) {
           return false
@@ -648,6 +659,7 @@ export default {
         if (oldValue) {
           this.dataForm.periodId = ''
         }
+        this.periodSelectedList = this.periodList.filter(item => item.pigstyId === newValue)
       }
     }
   }

+ 38 - 16
src/views/modules/breed/btransfer.vue

@@ -49,7 +49,9 @@
               </el-select>
             </el-form-item>
             <el-form-item style="width: 140px">
-              <el-select placeholder="猪舍" v-model="form.pigstyId" @change="pigstyChange">
+              <el-select 
+                placeholder="猪舍" 
+                v-model="form.pigstyId">
                 <el-option
                   v-for="item in pigstyList"
                   :key="item.value"
@@ -59,7 +61,11 @@
               </el-select>
             </el-form-item>
             <el-form-item style="width: 140px">
-              <el-select placeholder="单元" v-model="form.unitId" @change="ifPigsty('unitId')">
+              <el-select 
+                placeholder="单元" 
+                v-model="form.unitId" 
+                ref="unit"
+                @focus="selectFocus('unit')">
                 <el-option
                   v-for="item in unitSelectedList"
                   :key="item.value"
@@ -69,7 +75,11 @@
               </el-select>
             </el-form-item>
             <el-form-item style="width: 140px">
-              <el-select placeholder="栏期" v-model="form.periodId" @change="ifPigsty('periodId')">
+              <el-select 
+                placeholder="栏期" 
+                v-model="form.periodId" 
+                ref="period" 
+                @focus="selectFocus('period')">
                 <el-option
                   v-for="item in periodSelectedList"
                   :key="item.value"
@@ -285,11 +295,11 @@
         breedList: [],
         healthStatus: [
           {
-            value: true,
+            value: 1,
             label: '健康'
           },
           {
-            value: false,
+            value: 0,
             label: '不健康'
           }
         ],
@@ -400,13 +410,13 @@
           breedR.data.all && (breedList = breedR.data.all)
           breedList.forEach(breed => {
             let item = {
-              value: breed.id,
+              value: breed.name,
               label: breed.name
             }
             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
+          this.periodSelectedList = this.form.pigstyId? this.periodList.filter(item => item.pigstyId === this.form.pigstyId): this.periodList
+          this.unitSelectedList = this.form.pigstyId? this.unitList.filter(item => item.pigstyId === this.form.pigstyId): this.unitList
           // 获取猪只List
           if (data && data.code === 0) {
             this.dataList = data.page.list
@@ -419,18 +429,28 @@
           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) {
+      // 点击 单元or栏期的选择框
+      selectFocus (val) {
         if (!this.form.pigstyId) {
           this.$message.error('请先选择猪舍')
-          this.form[val] = ''
+          this.form[val + 'Id'] = ''
+          setTimeout(() => {
+            this.$refs[val].blur()
+          }, 10)
         }
       },
+      // // 根据栋舍选择限制单元和栏期
+      // 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) {
@@ -506,6 +526,8 @@
             this.form.unitId = ''
             this.form.periodId = ''
           }
+          this.unitSelectedList = this.unitList.filter(item => item.pigstyId === newValue)
+          this.periodSelectedList = this.periodList.filter(item => item.pigstyId === newValue)
         }
       }
     }

+ 1 - 1
src/views/modules/breed/btrecord.vue

@@ -296,8 +296,8 @@
         handler (newValue, oldValue) {
           if (oldValue) {
             this.form.newUnitId = ''
-            this.newUnitSelectedList = this.unitList.filter(item => item.pigstyId === newValue)
           }
+          this.newUnitSelectedList = this.unitList.filter(item => item.pigstyId === newValue)
         }
       }
     }

+ 46 - 3
src/views/modules/envir/ealarm.vue

@@ -57,6 +57,14 @@
                 删 除
               </el-button>
             </el-form-item>
+            <el-form-item>
+              <el-button 
+                icon="el-icon-download" 
+                type="danger" 
+                @click="exportExcel()">
+                导出Excel
+              </el-button>
+            </el-form-item>
           </el-form>
           
           <el-table
@@ -76,7 +84,7 @@
               align="center"
               width="50">
             </el-table-column>
-            <el-table-column
+            <!-- <el-table-column
               prop="farmName"
               header-align="center"
               align="center"
@@ -84,7 +92,7 @@
               <template slot-scope="scope">
                 <span>{{thresholdTypes[scope.row.thresholdType - 1].label}}</span>
               </template>
-            </el-table-column>
+            </el-table-column> -->
             <el-table-column
               header-align="center"
               align="center"
@@ -221,7 +229,7 @@
           params: this.$http.adornParams({
             'page': this.pageIndex,
             'limit': this.pageSize,
-            'thresholdType': this.form.thresholdType,
+            'thresholdType': this.form.thresholdType || undefined,
             'farmId': parseInt(this.$cookie.get('formFarmId'))
           })
         }).then(async({data}) => {
@@ -280,6 +288,41 @@
           this.$refs.addOrUpdate.init(id)
         })
       },
+      // 导出Excel
+      exportExcel () {
+        // this.$http({
+        //   url: this.$http.adornUrl('/management/thresholdManagement/exportXls'),
+        //   method: 'get',
+        //   params: this.$http.adornParams({
+        //     'thresholdType': this.form.thresholdType || undefined,
+        //     'farmId': parseInt(this.$cookie.get('formFarmId'))
+        //   })
+        // }).then()
+        // window.open(`http://192.168.1.57:88/api/management/thresholdManagement/exportXls?thresholdType=${this.form.thresholdType}&farmId=${parseInt(this.$cookie.get('formFarmId'))}`);
+        this.$http({
+          url: this.$http.adornUrl('/management/thresholdManagement/exportXls'),
+          method: 'get',
+          params: this.$http.adornParams({
+            'thresholdType': this.form.thresholdType || undefined,
+            'farmId': parseInt(this.$cookie.get('formFarmId'))
+          }),
+          responseType: 'blob'
+        }).then(({data}) => {
+          if (!data) {
+            this.$message.error('文件下载失败')
+            return
+          }
+          let url = window.URL.createObjectURL(new Blob([data], {type: 'application/vnd.ms-excel'}))
+          let link = document.createElement('a')
+          link.style.display = 'none'
+          link.href = url
+          link.setAttribute('download', '阈值列表.xls')
+          document.body.appendChild(link)
+          link.click()
+          document.body.removeChild(link)
+          window.URL.revokeObjectURL(url)
+        })
+      },
       // 删除
       deleteHandle (id) {
         var ids = id ? [id] : this.dataListSelections.map(item => {

+ 5 - 1
src/views/modules/pigbasic/pbadopt-charts/statistics.vue

@@ -20,7 +20,7 @@
                 start-placeholder="开始时间"
                 end-placeholder="结束时间"
                 :default-time="['08:00:00', '16:00:00']"
-                @change="initChartLine"
+                @change="timeChange"
                 value-format="yyyy-MM-dd HH:mm:ss">
               </el-date-picker>
             </el-form-item>
@@ -144,13 +144,17 @@
       },
       // 获取起始与结束时间
       timeChange (val) {
+        console.log(val);
         let start = new Date(val[0])
         let end = new Date(val[1])
         let now = new Date()
+        console.log(start);
         if (start > now || end > now) {
           this.form.time = []
           this.$message.error('请勿选择超出现在的时刻')
+          return
         }
+        this.initChartLine()
       },
       clickChange () {
         this.ifMonth = !this.ifMonth

+ 103 - 63
src/views/modules/pigbasic/pbbasic.vue

@@ -2,11 +2,12 @@
   <div class="pbbasic">
     <el-container>
       <el-header>
-        <div class="rect" style="padding-bottom: 10px">
+        <div class="rect rect-form">
           <el-form
             :inline="true"
             :model="searchForm"
-            size="mini">
+            size="mini"
+            style="height: 47px">
             <el-form-item style="width: 200px">
               <el-input placeholder="耳标" style="width: 200px" v-model="searchForm.eartag"></el-input>
             </el-form-item>
@@ -52,8 +53,7 @@
             <el-form-item style="width: 140px">
               <el-select placeholder="猪舍" 
                 style="width: 140px" 
-                v-model="searchForm.pigstyId" 
-                @change="pigstyChange">
+                v-model="searchForm.pigstyId">
                 <el-option
                   v-for="item in pigstyList"
                   :key="item.label"
@@ -66,6 +66,7 @@
               <el-select 
                 placeholder="单元" 
                 style="width: 140px" 
+                ref="unit"
                 v-model="searchForm.unitId" 
                 @focus="selectFocus('unit')">
                 <el-option
@@ -81,6 +82,7 @@
               <el-select 
                 placeholder="栏期" 
                 style="width: 140px" 
+                ref="period"
                 v-model="searchForm.periodId" 
                 @focus="selectFocus('period')">
                 <el-option
@@ -101,7 +103,7 @@
       </el-header>
       <!-- 表格 -->
       <el-main>
-        <div class="rect" style="margin-top: 20px">
+        <div class="rect rect-table">
           <el-form size="mini" :inline="true">
             <el-form-item>
               <el-button 
@@ -234,8 +236,7 @@
               :page-sizes="[10, 20, 30, 50, 100]"
               :page-size="pageSize"
               layout="total, sizes, prev, pager, next, jumper"
-              :total="totalPage"
-            >
+              :total="totalPage">
             </el-pagination>
           </div>
           <el-dialog
@@ -256,13 +257,12 @@
                 <el-select
                   v-model="form.pigstyId"
                   placeholder="请选择所属猪舍"
-                  @change="pigstyChange"
                   style="width: 100%">
                   <el-option
                     v-for="item in pigstyList"
-                    :key="item.id"
-                    :label="item.number"
-                    :value="item.id">
+                    :key="item.label"
+                    :label="item.label"
+                    :value="item.value">
                   </el-option>
                 </el-select>
               </el-form-item>
@@ -270,17 +270,16 @@
                 <el-select
                   v-model="form.unitId"
                   placeholder="请选择所属单元"
-                  @change="ifPigsty('unitId')"
                   style="width: 100%">
                   <el-option
                     v-for="item in unitSelectedList"
-                    :key="item.id"
-                    :label="item.number"
-                    :value="item.id">
+                    :key="item.label"
+                    :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="form.periodId"
                   placeholder="请选择所属栏期"
@@ -288,12 +287,12 @@
                   style="width: 100%">
                   <el-option
                     v-for="item in periodSelectedList"
-                    :key="item.id"
-                    :label="item.number"
-                    :value="item.id">
+                    :key="item.label"
+                    :label="item.label"
+                    :value="item.value">
                   </el-option>
                 </el-select>
-              </el-form-item>
+              </el-form-item> -->
               <el-form-item label="耳标" prop="eartag">
                 <el-input
                   v-model="form.eartag"
@@ -330,7 +329,7 @@
                   placeholder="请选择健康状况"
                   style="width: 100%">
                   <el-option
-                    v-for="item in health"
+                    v-for="item in healthStatus"
                     :key="item.label"
                     :label="item.label"
                     :value="item.value">
@@ -377,7 +376,7 @@ export default {
         breed: '',
         healthStatus: '',
         outFenceStatus: '',
-        periodId: '',
+        // periodId: '',
         pigstyId: '',
         unitId: ''
       },
@@ -400,7 +399,7 @@ export default {
         birthday: "",
         sex: "",
         pigstyId: "",
-        periodId: "",
+        // periodId: "",
         farmId: "",
       },
       // pastureList: [], // 牧场list
@@ -459,9 +458,9 @@ export default {
           { required: true, message: "猪舍不能为空", trigger: "blur" },
         ],
         unitId: [{ required: true, message: "单元不能为空", trigger: "blur" }],
-        periodId: [
-          { required: true, message: "栏期不能为空", trigger: "blur" },
-        ],
+        // periodId: [
+        //   { required: true, message: "栏期不能为空", trigger: "blur" },
+        // ],
         eartag: [{ required: true, message: "耳标不能为空", trigger: "blur" }],
         sex: [{ required: true, message: "性别不能为空", trigger: "blur" }],
         birthday: [
@@ -528,6 +527,7 @@ export default {
           }
           this.pigstyList.push(item)
         })
+        console.log(this.pigstyList);
         // 单元List
         this.unitList = []
         let unitList = []
@@ -545,7 +545,6 @@ export default {
           }
           this.unitList.push(item)
         })
-        this.unitSelectedList = this.unitList
         // 栏期List
         this.periodList = []
         let periodList = []
@@ -563,8 +562,8 @@ 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
+        this.periodSelectedList = this.searchForm.pigstyId? this.periodList.filter(item => item.pigstyId === this.searchForm.pigstyId): this.periodList
+        this.unitSelectedList = this.searchForm.pigstyId? this.unitList.filter(item => item.pigstyId === this.searchForm.pigstyId): this.unitList
         // 品种list
         this.breedList = []
         let breedList = []
@@ -576,7 +575,7 @@ export default {
         breedR.data.all && (breedList = breedR.data.all)
         breedList.forEach(breed => {
           let item = {
-            value: breed.id,
+            value: breed.name,
             label: breed.name
           }
           this.breedList.push(item)
@@ -634,17 +633,16 @@ export default {
         this.dataListLoading = false;
       });
     },
-    // FIXME: 还没改完
-    // 根据栋舍选择限制单元和栏期
-    pigstyChange (val) {
-      this.unitSelectedList = this.unitList.filter(item => item.pigstyId === val)
-      this.periodSelectedList = this.periodList.filter(item => item.pigstyId === val)
-    },
+    // // 根据栋舍选择限制单元和栏期
+    // 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) {
+      if (!this.searchForm.pigstyId) {
         this.$message.error('请先选择猪舍')
-        this.form[val + 'Id'] = ''
+        this.searchForm[val + 'Id'] = ''
         setTimeout(() => {
           this.$refs[val].blur()
         }, 10)
@@ -875,8 +873,22 @@ export default {
     addOrUpdateHandle(row) {
       // 显示牧场新增 or 修改面板
       this.visible = true;
+      console.log(row);
       if (row) {
-        this.form = row;
+        // this.form = row;
+        this.form.id = row.id
+        this.form.unitId = row.unitId
+        this.form.pigstyId = row.pigstyId
+        this.form.dayAge = row.dayAge
+        this.form.eartag = row.eartag
+        this.form.healthStatus = row.healthStatus
+        this.form.weight = row.weight
+        this.form.whereDidYouGo = row.whereDidYouGo
+        this.form.breed = row.breed
+        this.form.birthday = row.birthday
+        this.form.sex = row.sex
+        this.unitSelectedList = this.unitList.filter(item => item.pigstyId === this.form.pigstyId)
+        // this.form.periodId = row.periodId
       }
     },
     // 选择n个牧场
@@ -911,8 +923,8 @@ export default {
             data: this.$http.adornData(this.selectionDataList, false),
           }).then((result) => {
             if (result.data.code === 0) {
-              this.getDataList();
-              this.resetForm();
+              // this.getDataList();
+              // this.resetForm();
               this.$message({
                 message: "成功删除年猪",
                 type: "success",
@@ -957,21 +969,22 @@ export default {
             breed: this.form.breed,
             birthday: this.form.birthday,
             sex: this.form.sex,
-            periodId: this.form.periodId,
+            // periodId: this.form.periodId,
             pigstyId: this.form.pigstyId,
             farmId: parseInt(this.$cookie.get('formFarmId'))
           }),
         }).then((result) => {
           if (result.data.code === 0) {
-            this.resetForm();
-            console.log(result);
-            console.log(this.form);
+            // this.resetForm();
+            // console.log(result);
+            // console.log(this.form);
             this.visible = false;
             this.$message({
               message: "成功修改年猪信息",
               type: "success",
               duration: 1000,
-            });
+            })
+            // this.getDataList()
           } else {
             // TODO: 年猪耳标重复
             if (result.data.code === 600) {
@@ -1015,7 +1028,7 @@ export default {
             breed: this.form.breed,
             birthday: this.form.birthday,
             sex: this.form.sex,
-            periodId: this.form.periodId,
+            // periodId: this.form.periodId,
             pigstyId: this.form.pigstyId,
             farmId: parseInt(this.$cookie.get('formFarmId'))
           }),
@@ -1025,13 +1038,14 @@ export default {
             this.totalPage++;
             let pages = Math.ceil(this.totalPage / this.pageSize);
             this.pageIndex = this.pageIndex < pages ? pages : this.pageIndex;
-            this.resetForm();
+            // this.resetForm();
             // this.visible = false;
             this.$message({
               message: "成功添加年猪",
               type: "success",
               duration: 1000,
-            });
+            })
+            // this.getDataList()
           } else {
             // TODO: 年猪耳标重复
             if (result.data.code === 600) {
@@ -1050,6 +1064,7 @@ export default {
           }
         });
       }
+      this.getDataList()
     },
     // 校验输入是否完整
     validComplete(val) {
@@ -1059,7 +1074,7 @@ export default {
         delete this.form.fosterStatus,
         delete this.form.gmtCreate,
         delete this.form.gmtModified,
-        delete this.form.periodNumber,
+        // delete this.form.periodNumber,
         delete this.form.phNumber,
         delete this.form.unitNumber,
         delete this.form.name);
@@ -1127,24 +1142,43 @@ export default {
         .catch(() => {});
       return false;
     },
-    // 清空form
-    resetForm() {
-      // for (let i in this.form) {
-      //   this.form[i] = ''
-      // }
-      this.form.eartag = "";
-      this.getDataList();
-    },
+    // // 清空form
+    // resetForm() {
+    //   // for (let i in this.form) {
+    //   //   this.form[i] = ''
+    //   // }
+    //   this.form.eartag = "";
+    //   this.getDataList();
+    // },
     // 取消
     cancel() {
       this.visible = false;
-      this.resetForm();
+      // this.resetForm();
     },
   },
-  components: {
-    // pbbasicLeft,
-  },
-};
+  watch: {
+    'searchForm.pigstyId': {
+      handler(newValue, oldValue) {
+        if (oldValue) {
+          this.searchForm.unitId = ''
+          this.searchForm.periodId = ''
+        }
+        this.unitSelectedList = this.unitList.filter(item => item.pigstyId === newValue)
+        this.periodSelectedList = this.periodList.filter(item => item.pigstyId === newValue)
+      }
+    },
+    '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 {
@@ -1153,6 +1187,12 @@ export default {
   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;

+ 17 - 18
src/views/modules/pigbasic/pbentry-add-or-update.vue

@@ -24,8 +24,7 @@
       <el-form-item label="猪舍" prop="pigstyId">
         <el-select 
           v-model="dataForm.pigstyId"
-          style="width: 100%"
-          @change="pigstyChange">
+          style="width: 100%">
           <el-option
             v-for="item in pigstyList"
             :key="item.value"
@@ -37,8 +36,7 @@
       <el-form-item label="单元" prop="unitId">
         <el-select 
           v-model="dataForm.unitId"
-          style="width: 100%"
-          @change="ifPigsty('unitId')">
+          style="width: 100%">
           <el-option
             v-for="item in unitSelectedList"
             :key="item.value"
@@ -311,11 +309,11 @@
               value: unit.id,
               label: unit.number,
               pigstyId: unit.pigstyId,
-              farmId: unit.farmId
+              // farmId: unit.farmId
             }
             this.unitList.push(item)
           })
-          this.unitSelectedList = this.unitList
+          this.unitSelectedList = this.dataForm.pigstyId? this.unitList.filter(item => item.pigstyId === this.dataForm.pigstyId): this.unitList
           // 品种list
           let breedList = []
           let bloodR = await this.$http({
@@ -341,19 +339,19 @@
           })
         })
       },
-      // 根据栋舍选择限制单元和栏期
-      pigstyChange (val) {
-        this.unitSelectedList = this.unitList.filter(item => item.pigstyId === val)
-        console.log(this.unitSelectedList);
-        // this.periodSelectedList = this.periodList.filter(item => item.pigstyId === val)
-      },
+      // // 根据栋舍选择限制单元和栏期
+      // pigstyChange (val) {
+      //   this.unitSelectedList = this.unitList.filter(item => item.pigstyId === val)
+      //   console.log(this.unitSelectedList);
+      //   // this.periodSelectedList = this.periodList.filter(item => item.pigstyId === val)
+      // },
       // 需要先选择猪舍,才能选择单元或栏期
-      ifPigsty (val) {
-        if (!this.dataForm.pigstyId) {
-          this.$message.error('请先选择猪舍')
-          this.dataForm[val] = ''
-        }
-      },
+      // ifPigsty (val) {
+      //   if (!this.dataForm.pigstyId) {
+      //     this.$message.error('请先选择猪舍')
+      //     this.dataForm[val] = ''
+      //   }
+      // },
       // 表单提交
       dataFormSubmit () {
         this.$refs['dataForm'].validate((valid) => {
@@ -425,6 +423,7 @@
             this.dataForm.unitId = ''
             // this.dataForm.periodId = ''
           }
+          this.unitSelectedList = this.unitList.filter(item => item.pigstyId === newValue)
         }
       }
     }

+ 45 - 18
src/views/modules/pigbasic/pbentry.vue

@@ -1,12 +1,17 @@
 <template>
-  <div class="mod-role">
+  <div class="pbentry">
     <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 
+            :inline="true" 
+            :model="form" 
+            @keyup.enter.native="getDataList()" 
+            size="mini" 
+            ref="form">
+            <el-form-item style="width: 200px">
+              <el-input style="width: 200px" v-model="form.eartag" placeholder="耳标" clearable></el-input>
             </el-form-item>
             <el-form-item style="width: 140px">
               <el-select placeholder="性别" v-model="form.sex">
@@ -49,7 +54,9 @@
               </el-select>
             </el-form-item>
             <el-form-item style="width: 140px">
-              <el-select placeholder="猪舍" v-model="form.pigstyId" @change="pigstyChange">
+              <el-select 
+                placeholder="猪舍" 
+                v-model="form.pigstyId">
                 <el-option
                   v-for="item in pigstyList"
                   :key="item.value"
@@ -59,7 +66,11 @@
               </el-select>
             </el-form-item>
             <el-form-item style="width: 140px">
-              <el-select placeholder="单元" v-model="form.unitId" @change="ifPigsty('unitId')">
+              <el-select 
+                placeholder="单元" 
+                v-model="form.unitId" 
+                ref="unit"
+                @focus="selectFocus('unit')">
                 <el-option
                   v-for="item in unitSelectedList"
                   :key="item.value"
@@ -69,7 +80,11 @@
               </el-select>
             </el-form-item>
             <el-form-item style="width: 140px">
-              <el-select placeholder="栏期" v-model="form.periodId" @change="ifPigsty('periodId')">
+              <el-select 
+                placeholder="栏期" 
+                v-model="form.periodId" 
+                ref="period"
+                @focus="selectFocus('period')">
                 <el-option
                   v-for="item in periodSelectedList"
                   :key="item.value"
@@ -90,7 +105,7 @@
           </el-form>
         </div>
       </el-header>
-      <!-- role表格 -->
+      <!-- 表格 -->
       <el-main>
         <div class="rect rect-table">
           <!-- 新增 删除按钮 -->
@@ -408,8 +423,8 @@
             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
+          this.periodSelectedList = this.form.pigstyId? this.periodList.filter(item => item.pigstyId === this.form.pigstyId): this.periodList
+          this.unitSelectedList = this.form.pigstyId? this.unitList.filter(item => item.pigstyId === this.form.pigstyId): this.unitList
           // 品种List
           this.breedList = []
           let breedList = []
@@ -438,16 +453,26 @@
           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) {
+      // // 根据栋舍选择限制单元和栏期
+      // 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] = ''
+      //   }
+      // },
+      // 点击 单元or栏期的选择框
+      selectFocus (val) {
         if (!this.form.pigstyId) {
           this.$message.error('请先选择猪舍')
-          this.form[val] = ''
+          this.form[val + 'Id'] = ''
+          setTimeout(() => {
+            this.$refs[val].blur()
+          }, 10)
         }
       },
       // form表单清空,单元SelectedList 和 栏期SelectedList重置
@@ -526,6 +551,8 @@
             this.form.unitId = ''
             this.form.periodId = ''
           }
+          this.unitSelectedList = this.unitList.filter(item => item.pigstyId === newValue)
+          this.periodSelectedList = this.periodList.filter(item => item.pigstyId === newValue)
         }
       }
     }

+ 35 - 14
src/views/modules/pigbasic/pbexit.vue

@@ -49,7 +49,9 @@
               </el-select>
             </el-form-item>
             <el-form-item style="width: 140px">
-              <el-select placeholder="猪舍" v-model="form.pigstyId" @change="pigstyChange">
+              <el-select 
+                placeholder="猪舍" 
+                v-model="form.pigstyId">
                 <el-option
                   v-for="item in pigstyList"
                   :key="item.value"
@@ -59,7 +61,11 @@
               </el-select>
             </el-form-item>
             <el-form-item style="width: 140px">
-              <el-select placeholder="单元" v-model="form.unitId" @change="ifPigsty('unitId')">
+              <el-select 
+                placeholder="单元" 
+                v-model="form.unitId" 
+                ref="unit"
+                @focus="selectFocus('unit')">
                 <el-option
                   v-for="item in unitSelectedList"
                   :key="item.value"
@@ -69,7 +75,11 @@
               </el-select>
             </el-form-item>
             <el-form-item style="width: 140px">
-              <el-select placeholder="栏期" v-model="form.periodId" @change="ifPigsty('periodId')">
+              <el-select 
+                placeholder="栏期" 
+                v-model="form.periodId"
+                ref="period" 
+                @focus="selectFocus('period')">
                 <el-option
                   v-for="item in periodSelectedList"
                   :key="item.value"
@@ -407,8 +417,8 @@
             }
             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
+          this.periodSelectedList = this.form.pigstyId? this.periodList.filter(item => item.pigstyId === this.form.pigstyId): this.periodList
+          this.unitSelectedList = this.form.pigstyId? this.unitList.filter(item => item.pigstyId === this.form.pigstyId): this.unitList
           // 品种List
           this.breedList = []
           let breedList = []
@@ -437,16 +447,26 @@
           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) {
+      // // 根据栋舍选择限制单元和栏期
+      // 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] = ''
+      //   }
+      // },
+      // 点击 单元or栏期的选择框
+      selectFocus (val) {
         if (!this.form.pigstyId) {
           this.$message.error('请先选择猪舍')
-          this.form[val] = ''
+          this.form[val + 'Id'] = ''
+          setTimeout(() => {
+            this.$refs[val].blur()
+          }, 10)
         }
       },
       // form表单清空,单元SelectedList 和 栏期SelectedList重置
@@ -493,7 +513,6 @@
         var eartags = pig ? [pig.eartag] : this.dataListSelections.map(item => {
           return item.eartag
         })
-        let delLength = this.dataListSelections.length
         this.$confirm(`确定对[耳标=${eartags.join(',')}]进行[${pig ? '出栏' : '批量出栏'}]操作?`, '提示', {
           confirmButtonText: '确定',
           cancelButtonText: '取消',
@@ -528,6 +547,8 @@
             this.form.unitId = ''
             this.form.periodId = ''
           }
+          this.unitSelectedList = this.unitList.filter(item => item.pigstyId === newValue)
+          this.periodSelectedList = this.periodList.filter(item => item.pigstyId === newValue)
         }
       }
     }

+ 0 - 2
src/views/modules/pigbasic/pbped-details.vue

@@ -362,8 +362,6 @@
         }).then(({data}) => {
           if (data && data.code === 0) {
             this.dataList = data.Result.value
-            console.log(this.dataList);
-            console.log(data.Result.value);
           } else {
             this.dataList = []
             this.$message.error(data.msg)

+ 36 - 14
src/views/modules/pigbasic/pbpedigree.vue

@@ -49,7 +49,9 @@
               </el-select>
             </el-form-item>
             <el-form-item style="width: 140px">
-              <el-select placeholder="猪舍" v-model="form.pigstyId" @change="pigstyChange">
+              <el-select 
+                placeholder="猪舍" 
+                v-model="form.pigstyId">
                 <el-option
                   v-for="item in pigstyList"
                   :key="item.value"
@@ -59,7 +61,11 @@
               </el-select>
             </el-form-item>
             <el-form-item style="width: 140px">
-              <el-select placeholder="单元" v-model="form.unitId" @change="ifPigsty('unitId')">
+              <el-select 
+                placeholder="单元" 
+                v-model="form.unitId" 
+                ref="unit"
+                @focus="selectFocus('unit')">
                 <el-option
                   v-for="item in unitSelectedList"
                   :key="item.value"
@@ -69,7 +75,11 @@
               </el-select>
             </el-form-item>
             <el-form-item style="width: 140px">
-              <el-select placeholder="栏期" v-model="form.periodId" @change="ifPigsty('periodId')">
+              <el-select 
+                placeholder="栏期" 
+                v-model="form.periodId" 
+                ref="period"
+                @focus="selectFocus('period')">
                 <el-option
                   v-for="item in periodSelectedList"
                   :key="item.value"
@@ -94,7 +104,7 @@
       <el-main>
         <div class="rect rect-table">
           <!-- 新增 删除按钮 -->
-          <el-form inline size="mini">
+          <!-- <el-form inline size="mini">
             <el-form-item>
               <el-button 
                 icon="el-icon-plus" 
@@ -120,7 +130,7 @@
                 批量修改
               </el-button>
             </el-form-item>
-          </el-form>
+          </el-form> -->
           
           <el-table
             :data="dataList"
@@ -130,7 +140,7 @@
             @selection-change="selectionChangeHandle"
             style="width: 100%;"
             size="mini"
-            height="540"
+            height="587"
             :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
@@ -455,16 +465,26 @@
           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) {
+      // // 根据栋舍选择限制单元和栏期
+      // 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] = ''
+      //   }
+      // },
+      // 点击 单元or栏期的选择框
+      selectFocus (val) {
         if (!this.form.pigstyId) {
           this.$message.error('请先选择猪舍')
-          this.form[val] = ''
+          this.form[val + 'Id'] = ''
+          setTimeout(() => {
+            this.$refs[val].blur()
+          }, 10)
         }
       },
       // form表单清空,单元SelectedList 和 栏期SelectedList重置
@@ -541,6 +561,8 @@
             this.form.unitId = ''
             this.form.periodId = ''
           }
+          this.unitSelectedList = this.unitList.filter(item => item.pigstyId === newValue)
+          this.periodSelectedList = this.periodList.filter(item => item.pigstyId === newValue)
         }
       }
     }

+ 18 - 16
src/views/modules/pigbasic/pbzhong-add-or-update.vue

@@ -47,7 +47,7 @@
           </el-option>
         </el-select>
       </el-form-item>
-      <el-form-item label="源产地" prop="origin">
+      <!-- <el-form-item label="源产地" prop="origin">
         <el-select v-model="dataForm.origin" style="width: 100%">
           <el-option
             v-for="item in originList"
@@ -56,7 +56,7 @@
             :value="item.value">
           </el-option>
         </el-select>
-      </el-form-item>
+      </el-form-item> -->
       <el-form-item label="产仔窝数" prop="batchNp" v-if="dataForm.type!==1">
         <el-input v-model.number="dataForm.batchNp" placeholder="请输入数字">
         </el-input>
@@ -96,7 +96,7 @@
           type: '',
           birthDate: '',
           blood: '',
-          origin: '',
+          // origin: '',
           batchNp: '',
           pigletTotal: '',
           psy: '',
@@ -123,7 +123,7 @@
           ]
         },
         bloodList: [], // 品种list
-        originList: [], // 源产地list
+        // originList: [], // 源产地list
         type: [
           {
             value: 1,
@@ -176,21 +176,22 @@
           params: this.$http.adornParams({}, false)
         }).then(({data}) => {
           this.bloodList = []
-          this.originList = []
+          // this.originList = []
           let breedList = []
           if (data && data.code === 0) {
             breedList = data.all
             breedList.forEach(breed => {
               let item = {
                 value: breed.name,
-                label: breed.name
-              }
-              let item02 = {
-                value: breed.origin,
-                label: breed.origin
+                label: breed.name,
+                origin: breed.origin
               }
+              // let item02 = {
+              //   value: breed.origin,
+              //   label: breed.origin
+              // }
               this.bloodList.push(item)
-              this.originList.push(item02)
+              // this.originList.push(item02)
             })
           }
         })
@@ -210,11 +211,11 @@
                 'gender': this.dataForm.type < 2? 1: 2,
                 'birthDate': this.dataForm.birthDate,
                 'blood': this.dataForm.blood,
-                'origin': this.dataForm.origin,
-                'batchNp': this.dataForm.batchNp,
-                'pigletTotal': this.dataForm.pigletTotal,
-                'psy': this.dataForm.psy,
-                'remark': this.dataForm.remark
+                'origin': this.bloodList.filter(item => item.label === this.dataForm.blood)[0].origin,
+                'batchNp': this.dataForm.batchNp || undefined,
+                'pigletTotal': this.dataForm.pigletTotal || undefined,
+                'psy': this.dataForm.psy || undefined,
+                'remark': this.dataForm.remark || undefined
               }, false)
             }).then(({data}) => {
               if (data && data.code === 0) {
@@ -244,6 +245,7 @@
         let now = new Date();
         let days = now.getTime() - birth.getTime();
         if (days < 0) {
+          this.dataForm.birthDate = ''
           this.$confirm(`出生日期有误`, "提示", {
             confirmButtonText: "确定",
             cancelButtonText: "取消",