浏览代码

2022-01-19

East 3 年之前
父节点
当前提交
ea205bf57d

+ 5 - 4
src/components/modal-cpn/ModalCpn.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2022-01-08 16:02:11
- * @LastEditTime: 2022-01-17 14:39:15
+ * @LastEditTime: 2022-01-19 11:03:52
  * @LastEditors: Please set LastEditors
  * @Description: 新增 or 编辑表单
  * @FilePath: \goldenPig\src\components\form-cpn\FormCpn.vue
@@ -126,6 +126,10 @@ export default {
       type: Object,
       required: true,
     },
+    title: {
+      type: String,
+      default: "",
+    },
   },
   data() {
     return {
@@ -133,7 +137,6 @@ export default {
       needBlanks: 0,
       btnsBottom: false,
       dialogVisible: false,
-      title: "",
     };
   },
   methods: {
@@ -142,12 +145,10 @@ export default {
       this.dialogVisible = true;
       if (row.id) {
         this.dialogVisible = true;
-        // this.$nextTick(() => {
         for (const key in this.modalForm) {
           this.form[key] = row[key] ?? this.modalForm[key];
         }
         this.form.id = row.id;
-        // });
       } else {
         this.form = { ...this.modalForm };
       }

+ 8 - 4
src/components/newTable/NewTable.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2021-09-18 16:30:17
- * @LastEditTime: 2021-12-29 09:08:42
+ * @LastEditTime: 2022-01-19 16:04:26
  * @LastEditors: Please set LastEditors
  * @Description: 表格的封装
  * @FilePath: \hyyfClient\src\components\NewTable.vue
@@ -81,16 +81,20 @@ export default {
     },
     listData: {
       type: Array,
-      default: () => []
+      default: () => [],
     },
     shows: {
       type: Object,
       // defaultProp =>  需要特定条件的字段
-      default: () => ({ showIndex: false, showSelect: false, defaultProp: null }),
+      default: () => ({
+        showIndex: false,
+        showSelect: false,
+        defaultProp: null,
+      }),
     },
     tableItems: {
       type: Array,
-      default: () => []
+      default: () => [],
     },
     height: {
       // 表格高度控制

+ 2 - 2
src/components/search-cpn/SearchCpn.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2022-01-06 13:53:10
- * @LastEditTime: 2022-01-17 14:40:37
+ * @LastEditTime: 2022-01-19 14:48:01
  * @LastEditors: Please set LastEditors
  * @Description: 搜索组件
  * @FilePath: \goldenPig\src\components\search-cpn\SearchCpn.vue
@@ -118,12 +118,12 @@ export default {
   watch: {
     formItemProp: {
       handler(newVal) {
+        // 布局
         this.needBlanks = 3 - ((newVal.length + 1) % 3);
         if (this.needBlanks === 2) {
           this.btnsBottom = true;
         }
         this.form = { ...this.searchForm };
-        console.log(this.form);
       },
       deep: true,
       immediate: true,

+ 2 - 1
src/components/table-cpn/TableContent.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2022-01-08 14:47:24
- * @LastEditTime: 2022-01-12 14:09:09
+ * @LastEditTime: 2022-01-19 16:18:10
  * @LastEditors: Please set LastEditors
  * @Description: 表格
  * @FilePath: \goldenPig\src\components\table-cpn\TableContent.vue
@@ -19,6 +19,7 @@
 
     <div class="content">
       <el-table
+        empty-text="暂无数据"
         :data="dataList"
         :size="tableSize"
         :height="height"

+ 10 - 8
src/components/table-cpn/TableCpn.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2022-01-06 16:46:18
- * @LastEditTime: 2022-01-17 14:34:54
+ * @LastEditTime: 2022-01-19 16:29:32
  * @LastEditors: Please set LastEditors
  * @Description: 再封一次
  * @FilePath: \goldenPig\src\components\table-cpn\TableCpn.vue
@@ -124,10 +124,8 @@ export default {
     });
   },
   mounted() {
-    this.init();
-    const _this = this;
     EventBus.$on("refresh", () => {
-      _this.init();
+      this.init();
     });
   },
   watch: {
@@ -136,13 +134,14 @@ export default {
         this.init();
       },
       deep: true,
+      immediate: true,
     },
   },
   methods: {
     // 请求网络数据
     init() {
       for (const key in this.searchForm) {
-        this.searchForm[key] = this.searchForm[key] ?? undefined;
+        this.searchForm[key] = this.searchForm[key] || undefined;
       }
       this.requests
         .list({
@@ -154,10 +153,13 @@ export default {
           if (res?.code === 10000) {
             this.dataList = res.data.records;
             this.total = res.data.total;
+            this.requests.others?.forEach((fn) => {
+              fn();
+            });
           } else {
             this.dataList = [];
             this.total = 0;
-            this.$message.error(res.message);
+            res && this.$message.error(res.message);
           }
         });
     },
@@ -172,10 +174,10 @@ export default {
     handleDel(row) {
       this.requests.del({ ids: row.id }).then((res) => {
         if (res.code === 10000) {
-          this.$message.success(res.message);
+          res && this.$message.success(res.message);
           this.init();
         } else {
-          this.$message.error(res.message);
+          res && this.$message.error(res.message);
         }
       });
     },

+ 1 - 1
src/store/index.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2022-01-04 15:14:05
- * @LastEditTime: 2022-01-12 09:34:10
+ * @LastEditTime: 2022-01-19 15:30:51
  * @LastEditors: Please set LastEditors
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: \goldenPig\src\store\index.js

+ 10 - 2
src/views/basic-data/archives-admin/ArchivesAdmin.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2022-01-08 10:36:06
- * @LastEditTime: 2022-01-17 14:42:20
+ * @LastEditTime: 2022-01-19 15:49:13
  * @LastEditors: Please set LastEditors
  * @Description: 基础资料 - 档案管理
  * @FilePath: \goldenPig\src\views\basic-data\archives-admin\ArchivesAdmin.vue
@@ -79,6 +79,8 @@ import {
   baseFarmDel,
 } from "@/utils/apis/basic-data/archivesAdmin.js";
 
+import { mapActions } from "vuex";
+
 export default {
   components: {
     SearchCpn,
@@ -97,7 +99,11 @@ export default {
         location: [],
       },
       options: regionData,
-      searchForm: {},
+      searchForm: {
+        farmName: undefined,
+        type: undefined,
+        location: undefined,
+      },
       // 表格
       tableConfig: {},
       tableDataList: [],
@@ -122,6 +128,7 @@ export default {
       requests: {
         list: baseFarmList,
         del: baseFarmDel,
+        others: [this.GetFarm],
       },
       tableStyle: {
         height: 500,
@@ -137,6 +144,7 @@ export default {
     };
   },
   methods: {
+    ...mapActions(["GetFarm"]),
     // 查询按钮 - 获取参数
     handleSearchEvent(params) {
       this.searchForm = {

+ 1 - 1
src/views/basic-data/archives-admin/config/search.config.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2022-01-06 14:44:20
- * @LastEditTime: 2022-01-11 08:44:11
+ * @LastEditTime: 2022-01-19 15:58:47
  * @LastEditors: Please set LastEditors
  * @Description: 养殖企业 - 搜索配置
  * @FilePath: \goldenPig\src\views\summary-data\individual-data\search.config.js

+ 112 - 90
src/views/basic-data/house-admin/HouseAdmin.vue

@@ -1,19 +1,36 @@
 <!--
  * @Author: your name
  * @Date: 2022-01-08 10:36:43
- * @LastEditTime: 2022-01-12 15:58:00
+ * @LastEditTime: 2022-01-19 16:29:18
  * @LastEditors: Please set LastEditors
  * @Description: 基础资料 - 栋舍管理
  * @FilePath: \goldenPig\src\views\basic-data\house-admin\HouseAdmin.vue
 -->
 <template>
   <div class="house-admin">
-    <!-- <search-cpn
+    <search-cpn
       v-bind="searchConfig"
       @handleSearch="handleSearchEvent"
       @clearEvent="handleClearEvent"
     >
-    </search-cpn> -->
+      <template #farmId="scope">
+        <el-select
+          v-model="searchForm2.farmId"
+          :placeholder="scope.item.placeholder"
+          style="width: 100%"
+          clearable
+          v-if="userItem.type === 0"
+        >
+          <el-option
+            v-for="option in farmList"
+            :key="option.id"
+            :value="option.id"
+            :label="option.farmName"
+          >
+          </el-option>
+        </el-select>
+      </template>
+    </search-cpn>
 
     <table-cpn
       v-bind="tableConfig"
@@ -22,33 +39,21 @@
     >
       <!-- 状态 -->
       <template #tempAnomaly="scope">
-        {{ statuses[scope.row.tempAnomaly] }}
+        {{ statuses[scope.row.tempAnomaly - 1] }}
       </template>
 
       <!-- 阶段 -->
       <template #stage="scope">
-        {{ stages[scope.row.stage - 1] }}
+        {{ stageList[scope.row.stage - 1].label }}
       </template>
     </table-cpn>
 
-    <modal-cpn ref="modal" v-bind="modalConfig" :otherParams="modalForm2">
-      <!-- 牧场名称 -->
-      <template #farmId="scope">
-        <el-select
-          v-model="modalForm2.farmId"
-          :placeholder="scope.item.placeholder"
-          style="width: 100%"
-          clearable
-        >
-          <el-option
-            v-for="option in farmList"
-            :key="option.label"
-            v-bind="option"
-          >
-          </el-option>
-        </el-select>
-      </template>
-
+    <modal-cpn
+      ref="modal"
+      v-bind="modalConfig"
+      :otherParams="modalForm2"
+      :title="title"
+    >
       <!-- 上级 -->
       <template #parentId="scope">
         <el-cascader
@@ -56,7 +61,6 @@
           :props="{ checkStrictly: true }"
           :value="pigpenSelected"
           :disabled="optionsDisabled"
-          @focus="handlePigpenFocus"
           @change="submitParentId"
           :placeholder="scope.item.placeholder"
           style="width: 100%"
@@ -68,8 +72,8 @@
 </template>
 <script>
 // 搜索
-// import SearchCpn from "@/components/search-cpn";
-// import { formItemProp } from "./config/search.config";
+import SearchCpn from "@/components/search-cpn";
+import { formItemProp } from "./config/search.config";
 
 // 表格
 import TableCpn from "@/components/table-cpn";
@@ -87,45 +91,48 @@ import {
   basePigpenOptions, // 栋舍表二级,用于模态框
 } from "@/utils/apis/basic-data/houseAdmin.js";
 
-import { baseFarmAll } from "@/utils/apis/basic-data/archivesAdmin.js";
+// import { baseFarmAll } from "@/utils/apis/basic-data/archivesAdmin.js";
+
+// Vuex
+import { mapState } from "vuex";
 
 export default {
   components: {
-    // SearchCpn,
+    SearchCpn,
     TableCpn,
     ModalCpn,
   },
+  computed: {
+    ...mapState(["farmList", "farmId", "stageList"]),
+  },
   data() {
     return {
+      userItem: null, // 用户身份
       // 搜索
       searchConfig: {},
       searchForm1: {
-        farmId: "",
-        parentId: "",
-        pigpenName: "",
-        pigpenTemp: "",
-        tempAnomaly: "",
-        stage: "",
+        pigpenName: undefined,
       },
       searchForm2: {
-        location: [],
+        farmId: undefined,
+      },
+      searchForm: {
+        pigpenName: undefined,
+        farmId: undefined,
       },
-      searchForm: {},
       // 表格
       tableConfig: {},
       tableDataList: [],
-      stages: ["保育", "配怀", "分娩"],
-      statuses: ["异常", "正常"],
+      statuses: ["正常", "异常"],
       // 新增 or 编辑
       modalConfig: {},
+      title: "",
       modalForm1: {
         pigpenName: "",
         pigpenTemp: "",
-        tempAnomaly: "",
+        tempAnomaly: 1,
         stage: "",
       },
-      farmList: [], // 名下所有牧场
-      pigpenAllList: [], // 所有的栋舍(二级)
       pigpenList: [], // 根据牧场所确定的栋舍(二级)
       pigpenSelected: [],
       modalForm2: {
@@ -137,7 +144,17 @@ export default {
     };
   },
   created() {
-    // this.searchConfig = { formItemProp, searchForm: this.searchForm1 };
+    // 获取用户身份
+    this.userItem = JSON.parse(localStorage.getItem("gold_UserItem"));
+    if (this.userItem.type === 0 && this.farmList.length > 0) {
+      this.searchForm2.farmId = this.farmList[0]?.id;
+      this.searchForm.farmId = this.farmList[0]?.id;
+      this.modalForm2.farmId = this.farmList[0]?.id;
+    }
+    this.searchConfig = {
+      formItemProp,
+      searchForm: { ...this.searchForm1 },
+    };
     this.tableConfig = {
       propList,
       permission: "archivesAdmin",
@@ -159,6 +176,38 @@ export default {
         edit: basePigpenEdit,
       },
     };
+    this.modalConfig.modalItemProp[4].options = this.stageList;
+  },
+  watch: {
+    farmId: {
+      handler(newVal) {
+        if (!newVal) {
+          return;
+        }
+        if (this.userItem && this.userItem.type !== 0) {
+          // 确定默认选中牧场
+          this.searchForm2.farmId = newVal;
+          this.searchForm.farmId = newVal;
+          this.modalForm2.farmId = newVal;
+        }
+      },
+      immediate: true,
+    },
+    farmList: {
+      handler(newVal) {
+        if (!newVal) {
+          return;
+        }
+        if (this.userItem && this.userItem.type === 0) {
+          // 确定默认选中牧场
+          this.searchForm2.farmId = newVal[0]?.id;
+          this.searchForm.farmId = newVal[0]?.id;
+          this.modalForm2.farmId = newVal[0]?.id;
+        }
+      },
+      immediate: true,
+      deep: true,
+    },
   },
   methods: {
     // 查询按钮 - 获取参数
@@ -170,38 +219,29 @@ export default {
     },
     // 清空数据
     handleClearEvent() {
-      this.searchForm2.location = [];
+      this.searchForm2.farmId = undefined;
+      this.searchForm.farmId = undefined;
     },
     // 模态框的 上级
     submitParentId(val) {
       this.modalForm2.parentId = val[val.length - 1];
       this.modalForm2.type = val.length;
-      // this.modalForm2.location = val.join();
-    },
-    // 选择上级之前,需要先选择牧场名称
-    handlePigpenFocus() {
-      if (!this.modalForm2.farmId) {
-        this.$message.warning("请先选择牧场名称");
-      }
     },
     // 新增 or 编辑事件
     async handleAddOrEditEvent(row) {
-      this.modalForm2.farmId = "";
-      /* 牧场选择 */
-      const { code, data, message } = await baseFarmAll({});
-      if (code === 10000) {
-        this.farmList = data.map((item) => {
-          return {
-            value: item.id,
-            label: item.farmName,
-          };
-        });
-      } else {
-        this.$message.error(message, "无法选择牧场");
-        return;
+      // 牧场
+      this.modalForm2.farmId = this.searchForm2.farmId;
+      /* 模态框标题 - 牧场名称 */
+      if (this.userItem.type === 0) {
+        const farm = this.farmList.find(
+          (item) => item.id === this.modalForm2.farmId
+        );
+        this.title = farm.farmName;
       }
       /* 栋舍表二级 */
-      const pigpenOptions = await basePigpenOptions({});
+      const pigpenOptions = await basePigpenOptions({
+        farmId: this.modalForm2.farmId,
+      });
       if (pigpenOptions.code === 10000) {
         // 递归函数:使返回值符合级联选择器的 label value
         const recursive = (arr) => {
@@ -217,13 +257,17 @@ export default {
             };
           });
         };
-        this.pigpenAllList = recursive(pigpenOptions.data);
+        this.pigpenList = [
+          {
+            label: "顶级",
+            value: 0,
+            children: recursive(pigpenOptions.data),
+          },
+        ];
       } else {
-        this.$message.error(message, "无法选择上级");
+        this.$message.error(pigpenOptions.message, "无法选择上级");
         return;
       }
-
-      // this.modalConfig.modalItemProp[0].options = allFarms.
       this.$refs["modal"].init(row);
       if (row.id) {
         this.modalForm2.farmId = row.farmId;
@@ -237,33 +281,11 @@ export default {
           this.pigpenSelected = [0];
         }
       } else {
-        this.modalForm2.farmId = "";
         this.pigpenSelected = [];
         this.modalForm2.type = "";
       }
     },
   },
-  watch: {
-    "modalForm2.farmId": {
-      handler(newVal) {
-        this.optionsDisabled = false;
-        if (!newVal) {
-          this.optionsDisabled = false;
-          return;
-        }
-        let pigpenList = this.pigpenAllList.filter((item) => {
-          return item.farmId === this.modalForm2.farmId;
-        });
-        this.pigpenList = [
-          {
-            label: "顶级",
-            value: 0,
-            children: pigpenList,
-          },
-        ];
-      },
-    },
-  },
 };
 </script>
 <style scoped></style>

+ 5 - 27
src/views/basic-data/house-admin/config/modal.config.js

@@ -1,22 +1,13 @@
 /*
  * @Author: your name
  * @Date: 2022-01-08 16:08:30
- * @LastEditTime: 2022-01-17 14:32:15
+ * @LastEditTime: 2022-01-19 15:59:02
  * @LastEditors: Please set LastEditors
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: \goldenPig\src\views\basic-data\archives-admin\config\modal.config.js
  */
 export const modalItemProp = [
   {
-    label: '牧场名称:',
-    type: 'custom',
-    field: 'farmId',
-    placeholder: '请选择牧场名称',
-    options: [],
-    slotName: 'farmId',
-    rules: [{ required: true, message: '牧场不能为空', trigger: 'change' }]
-  },
-  {
     label: '上级:',
     type: 'custom',
     field: 'parentId',
@@ -25,10 +16,10 @@ export const modalItemProp = [
     rules: [{ required: true, message: '上级不能为空', trigger: 'change'}]
   },
   {
-    label: '栋/楼/单元 名称:',
+    label: '栋/楼/单元名称:',
     type: 'input',
     field: 'pigpenName',
-    placeholder: '请输入栋名称',
+    placeholder: '请输入栋/楼/单元名称',
     rules: [{ required: true, message: '名称不能为空', trigger: 'blur'}]
   },
   {
@@ -48,7 +39,7 @@ export const modalItemProp = [
         label: '正常'
       },
       {
-        value: 0,
+        value: 2,
         label: '异常'
       }
     ]
@@ -58,20 +49,7 @@ export const modalItemProp = [
     type: 'select',
     field: 'stage',
     placeholder: '请选择状态',
-    options: [
-      {
-        value: 1,
-        label: '保育'
-      },
-      {
-        value: 2,
-        label: '配怀'
-      },
-      {
-        value: 3,
-        label: '分娩'
-      }
-    ],
+    options: [],
     rules: [{ required: true, message: '阶段不能为空', trigger: 'change'}]
   },
 ]

+ 8 - 28
src/views/basic-data/house-admin/config/search.config.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2022-01-06 14:44:20
- * @LastEditTime: 2022-01-11 14:37:58
+ * @LastEditTime: 2022-01-19 09:26:14
  * @LastEditors: Please set LastEditors
  * @Description: 养殖企业 - 搜索配置
  * @FilePath: \goldenPig\src\views\summary-data\individual-data\search.config.js
@@ -9,35 +9,15 @@
 export const formItemProp = [
   {
     label: '牧场名称:',
-    type: 'input',
-    field: 'farmName',
-    placeholder: '请选择牧场名称',
+    type: 'custom',
+    field: 'farmId',
+    slotName: 'farmId',
+    placeholder: '请选择牧场'
   },
   {
     label: '栋舍名称:',
-    type: 'custom',
+    type: 'input',
     field: 'pigpenName',
-    slotName: 'pigpenName',
-    placeholder: '请选择位置'
-  },
-  {
-    label: '企业类型:',
-    type: 'select',
-    field: 'type',
-    placeholder: '请选择企业类型',
-    options: [
-      {
-        label: '屠宰企业',
-        value: 1
-      },
-      {
-        label: '养殖企业',
-        value: 2
-      },
-      {
-        label: '检疫机构',
-        value: 3
-      }
-    ]
-  },
+    placeholder: '请输入栋/楼/单元名称'
+  }
 ]

+ 2 - 7
src/views/basic-data/house-admin/config/table.config.js

@@ -1,19 +1,14 @@
 /*
  * @Author: your name
  * @Date: 2022-01-07 14:43:27
- * @LastEditTime: 2022-01-12 14:30:07
+ * @LastEditTime: 2022-01-19 10:05:24
  * @LastEditors: Please set LastEditors
  * @Description: 养殖企业 - 表格配置
  * @FilePath: \goldenPig\src\views\summary-data\individual-data\config\table.config.js
  */
 export const propList = [
-  // {
-  //   label: '牧场名称',
-  //   prop: 'farmName',
-  //   slotName: 'farmName'
-  // },
   {
-    label: '栋名称',
+    label: '栋/楼/单元名称',
     prop: 'pigpenName',
     slotName: 'pigpenName',
     align: 'left'

+ 130 - 109
src/views/eartag-admin/eartag-data/EartagData.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2022-01-08 10:32:53
- * @LastEditTime: 2022-01-08 14:35:06
+ * @LastEditTime: 2022-01-19 09:21:35
  * @LastEditors: Please set LastEditors
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: \goldenPig\src\views\eartag-admin\eartag-data\EartagData.vue
@@ -12,7 +12,12 @@
       <el-form :inline="true" label-width="80px" size="mini" :model="form">
         <el-form-item label="采集牧场" v-if="userItem.type !== 2">
           <el-select v-model="form.farm">
-            <el-option v-for="item in farmList" :key="item.id" :value="item.id" :label="item.farmName"></el-option>
+            <el-option
+              v-for="item in farmList"
+              :key="item.id"
+              :value="item.id"
+              :label="item.farmName"
+            ></el-option>
           </el-select>
         </el-form-item>
         <el-form-item label="采集时间">
@@ -24,7 +29,8 @@
             start-placeholder="开始日期"
             end-placeholder="结束日期"
             value-format="yyyy-MM-dd HH:mm:ss"
-            style="width: 100%;">
+            style="width: 100%;"
+          >
           </el-date-picker>
         </el-form-item>
         <el-form-item label="耳标号:">
@@ -32,7 +38,12 @@
         </el-form-item>
         <el-form-item label="阶段:">
           <el-select v-model="form.stage">
-            <el-option v-for="item in stageList" :key="item.value" :value="item.value" :label="item.label"></el-option>
+            <el-option
+              v-for="item in stageList"
+              :key="item.value"
+              :value="item.value"
+              :label="item.label"
+            ></el-option>
           </el-select>
         </el-form-item>
         <el-form-item label="基站编码">
@@ -45,36 +56,44 @@
       </el-form>
     </div>
     <div>
-      <new-table v-loading="loading" :height="600" :title="earTitle" :listData="list" :tableItems="tableItems">
+      <new-table
+        v-loading="loading"
+        :height="600"
+        :title="earTitle"
+        :listData="list"
+        :tableItems="tableItems"
+      >
         <template #earTemp="scope">
-          <el-tag style="width: 65px;">{{scope.row.earTemp}}℃</el-tag>
+          <el-tag style="width: 65px;">{{ scope.row.earTemp }}℃</el-tag>
         </template>
         <template #envTemp="scope">
-          <span>{{scope.row.envTemp}}℃</span>
+          <span>{{ scope.row.envTemp }}℃</span>
         </template>
         <template #rssi="scope">
-          <span>-{{scope.row.rssi}}db</span>
+          <span>-{{ scope.row.rssi }}db</span>
         </template>
         <template #stage="scope">
-          <span>{{getStage(scope.row.stage)}}</span>
+          <span>{{ getStage(scope.row.stage) }}</span>
         </template>
         <template #dong="scope">
-          <span>{{scope.row.penName}}{{scope.row.unitName}}</span>
+          <span>{{ scope.row.penName }}{{ scope.row.unitName }}</span>
         </template>
         <template #hander="scope">
-          <el-button size="mini" type="text" @click="jump(scope.row)">查看详情</el-button>
+          <el-button size="mini" type="text" @click="jump(scope.row)"
+            >查看详情</el-button
+          >
         </template>
       </new-table>
       <table-footer
         :totals="total"
         :size="size"
         @sizeChange="sizeChange"
-        @pageChange="pageChange"></table-footer>
+        @pageChange="pageChange"
+      ></table-footer>
     </div>
   </div>
 </template>
 <script>
-
 import { getEarTagList } from "@/utils/apis/eartag-data/eartagData";
 import { mapState, mapActions } from "vuex";
 import NewTable from "@/components/newTable/NewTable";
@@ -83,99 +102,99 @@ import TableFooter from "@/components/TableFooter";
 export default {
   components: {
     NewTable,
-    TableFooter
+    TableFooter,
   },
   computed: {
-    ...mapState(['stageList', 'farmList'])
+    ...mapState(["stageList", "farmList"]),
   },
   data() {
     return {
       form: {
-        farm: '',
+        farm: "",
         date: [],
-        eartagNo: '',
-        stage: '',
-        deviceCode: '',
+        eartagNo: "",
+        stage: "",
+        deviceCode: "",
       },
       total: 0,
       pageNum: 1,
       size: 10,
-      earTitle: '耳标数据列表',
+      earTitle: "耳标数据列表",
       list: [],
       loading: false,
       tableItems: [
         {
-          prop: 'time',
-          label: '采集时间',
-          minWidth: '100',
-          slotName: 'time'
+          prop: "time",
+          label: "采集时间",
+          minWidth: "100",
+          slotName: "time",
         },
         {
-          prop: 'eartagNo',
-          label: '耳标号',
-          minWidth: '100',
-          slotName: 'eartagNo'
+          prop: "eartagNo",
+          label: "耳标号",
+          minWidth: "100",
+          slotName: "eartagNo",
         },
         {
-          label: '耳根温度',
-          minWidth: '50',
-          slotName: 'earTemp'
+          label: "耳根温度",
+          minWidth: "50",
+          slotName: "earTemp",
         },
         {
-          label: '环境温度',
-          minWidth: '50',
-          slotName: 'envTemp'
+          label: "环境温度",
+          minWidth: "50",
+          slotName: "envTemp",
         },
         {
-          prop: 'exercise',
-          label: '运动量',
-          minWidth: '50',
-          slotName: 'exercise'
+          prop: "exercise",
+          label: "运动量",
+          minWidth: "50",
+          slotName: "exercise",
         },
         {
-          prop: 'bat',
-          label: '电池电量',
-          minWidth: '50',
-          slotName: 'bat'
+          prop: "bat",
+          label: "电池电量",
+          minWidth: "50",
+          slotName: "bat",
         },
         {
-          label: '信号强度',
-          minWidth: '50',
-          slotName: 'rssi'
+          label: "信号强度",
+          minWidth: "50",
+          slotName: "rssi",
         },
         {
-          label: '阶段',
-          minWidth: '50',
-          slotName: 'stage'
+          label: "阶段",
+          minWidth: "50",
+          slotName: "stage",
         },
         {
-          label: '栋舍',
-          minWidth: '100',
-          slotName: 'dong'
+          label: "栋舍",
+          minWidth: "100",
+          slotName: "dong",
         },
         {
-          prop: 'deviceCode',
-          label: '采集器编码',
-          minWidth: '100',
-          slotName: 'deviceCode'
+          prop: "deviceCode",
+          label: "采集器编码",
+          minWidth: "100",
+          slotName: "deviceCode",
         },
         {
-          prop: 'registeCode',
-          label: '机器编码',
-          minWidth: '100',
-          slotName: 'registeCode'
+          prop: "registeCode",
+          label: "机器编码",
+          minWidth: "100",
+          slotName: "registeCode",
         },
         {
-          prop: 'orgName',
-          label: '牧场名字',
-          minWidth: '100',
-          slotName: 'orgName'
+          prop: "orgName",
+          label: "牧场名字",
+          minWidth: "100",
+          slotName: "orgName",
         },
         {
-          label: '操作',
-          minWidth: '50',
-          slotName: 'hander'
-        }
+          label: "操作",
+          minWidth: "50",
+          slotName: "hander",
+        },
       ],
       userItem: null,
     };
@@ -188,88 +207,90 @@ export default {
     },
     // 修改页数
     pageChange(val) {
-      this.pageNum= val;
+      this.pageNum = val;
       this.init();
     },
-    ...mapActions(['GetFarm']),
+    ...mapActions(["GetFarm"]),
     search() {
       this.loading = true;
       this.pageNum = 1;
       let params = {
         page: this.pageNum,
         limit: this.size,
-      }
-      if(this.form.eartagNo !== '') {
+      };
+      if (this.form.eartagNo !== "") {
         params.eartagNo = this.form.eartagNo;
       }
-      if(this.form.date.length > 0) {
+      if (this.form.date.length > 0) {
         params.starTime = this.form.date[0];
-        params.endTime = this.form.date[1]
+        params.endTime = this.form.date[1];
       }
-      if(this.form.stage !== '') {
+      if (this.form.stage !== "") {
         params.state = this.form.state;
       }
-      if(this.form.deviceCode !== '') {
-        params.deviceCode = this.form.deviceCode
+      if (this.form.deviceCode !== "") {
+        params.deviceCode = this.form.deviceCode;
       }
-      getEarTagList(params).then(res => {
-        if(res.code === 0) {
-          this.list = res.page.list;
-          this.total = res.page.totalCount;
-        }
-        this.loading = false;
-      })
-        .catch(() => {
+      getEarTagList(params)
+        .then((res) => {
+          if (res.code === 0) {
+            this.list = res.page.list;
+            this.total = res.page.totalCount;
+          }
           this.loading = false;
         })
+        .catch(() => {
+          this.loading = false;
+        });
     },
     init() {
       this.loading = true;
       let params = {
         page: this.pageNum,
         limit: this.size,
-      }
-      getEarTagList(params).then(res => {
-        if(res.code === 0) {
-          this.list = res.page.list;
-          this.total = res.page.totalCount;
-        }
-        this.loading = false;
-      })
-      .catch(() => {
-        this.loading = false;
-      })
+      };
+      getEarTagList(params)
+        .then((res) => {
+          if (res.code === 0) {
+            this.list = res.page.list;
+            this.total = res.page.totalCount;
+          }
+          this.loading = false;
+        })
+        .catch(() => {
+          this.loading = false;
+        });
     },
     getStage(id) {
-       let data = this.stageList.find(item => {
-         return item.value == id
-      })
-      return data.label
+      let data = this.stageList.find((item) => {
+        return item.value == id;
+      });
+      return data.label;
     },
     jump(item) {
       this.$router.push({
-        path: '/earTagDetail',
+        path: "/earTagDetail",
         query: {
-          id: item.eartagNo
-        }
+          id: item.eartagNo,
+        },
       });
     },
     reset() {
-      this.form =  {
+      this.form = {
         farm: this.farmList[0].id,
         date: [],
-        eartagNo: '',
-        stage: '',
-        deviceCode: '',
-      }
+        eartagNo: "",
+        stage: "",
+        deviceCode: "",
+      };
     },
   },
   created() {
-    this.userItem = JSON.parse(localStorage.getItem('gold_UserItem'))
+    this.userItem = JSON.parse(localStorage.getItem("gold_UserItem"));
     this.GetFarm();
   },
   mounted() {
-    this.init()
+    this.init();
     this.form.farm = this.farmList[0].id;
   },
 };