Browse Source

2021-06-11

East 3 years ago
parent
commit
6bfda9ff72

+ 36 - 31
src/views/modules/pigbasic/pbbasic.vue

@@ -2,12 +2,12 @@
   <div class="pbbasic">
     <el-container>
       <!-- 树状图 -->
-      <el-aside>
+      <!-- <el-aside>
         <div class="rect">
           <pbbasic-left @getPigs="getPigs"></pbbasic-left>
         </div>
       </el-aside>
-      <el-container>
+      <el-container> -->
         <!-- form表单 -->
         <el-header>
           <div class="rect" style="padding-bottom: 10px">
@@ -130,14 +130,12 @@
               </el-form-item> -->
               <el-form-item>
                 <el-button 
-                  style="background-color: rgb(24,144,255);color: #fff;border-color: rgb(24,144,255);width: 90px;height: 30px;font-size: 13px" 
                   icon="el-icon-plus">
-                  新增
+                  新 
                 </el-button>
                 <el-button 
-                  style="background-color: rgb(24,144,255);color: #fff;border-color: rgb(24,144,255);width: 115px;height: 30px;font-size: 14px" 
                   icon="el-icon-delete">
-                  删除
+                  删 
                 </el-button>
               </el-form-item>
             </el-form>
@@ -382,9 +380,9 @@
                 label-width="80px"
                 size="mini"
                 style="padding: 0 60px 0 40px">
-                <el-form-item label="所属牧场" prop="pastureId">
+                <el-form-item label="所属牧场" prop="farmId">
                   <el-select
-                    v-model="form.pastureId"
+                    v-model="form.farmId"
                     placeholder="请选择所属牧场"
                     @change="getPasture"
                     ref="pasture"
@@ -515,13 +513,13 @@
             </el-dialog>
           </div>
         </el-main>
-      </el-container>
+      <!-- </el-container> -->
     </el-container>
   </div>
 </template>
 
 <script>
-import pbbasicLeft from "./pbbasicLeft";
+// import pbbasicLeft from "./pbbasicLeft";
 
 export default {
   data() {
@@ -556,7 +554,7 @@ export default {
         sex: "",
         pigstyId: "",
         periodId: "",
-        pastureId: "",
+        farmId: "",
       },
       pastureList: [], // 牧场list
       pighouseList: [], // 猪舍list
@@ -587,7 +585,7 @@ export default {
       ],
       row: {},
       dataRule: {
-        pastureId: [
+        farmId: [
           { required: true, message: "牧场不能为空", trigger: "blur" },
         ],
         pigstyId: [
@@ -606,7 +604,14 @@ export default {
         weight: [],
         breed: [{ required: true, message: "品种不能为空", trigger: "blur" }],
       },
-      labelPosition: 'right'
+      labelPosition: 'right',
+      searchForm: {
+        earTag: '',
+        sex: '',
+        breed: '',
+        health: '',
+        
+      }
     };
   },
   mounted() {
@@ -632,7 +637,7 @@ export default {
       }).then(async ({ data }) => {
         // 获取所有牧场
         let pastureResult = await this.$http({
-          url: this.$http.adornUrl("/management/pasture/findAll"),
+          url: this.$http.adornUrl("/management/farm/findAll"),
           method: "post",
         });
         pastureResult.data.all && (this.pastureList = pastureResult.data.all);
@@ -664,7 +669,7 @@ export default {
             for (let unit of this.unitList) {
               if (item.unitId === unit.id) {
                 item.unitNumber = unit.number;
-                item.pastureId = unit.pastureId;
+                item.farmId = unit.farmId;
                 item.pigstyId = unit.pigstyId;
                 break;
               }
@@ -673,7 +678,7 @@ export default {
           // 牧场对应
           this.dataList.forEach((item) => {
             for (let pasture of this.pastureList) {
-              if (item.pastureId === pasture.id) {
+              if (item.farmId === pasture.id) {
                 item.name = pasture.name;
                 break;
               }
@@ -769,39 +774,39 @@ export default {
       //  → 限制猪舍
       this.phSelectedList = [];
       this.pighouseList.forEach((item) => {
-        if (item.pastureId === val) {
+        if (item.farmId === val) {
           this.phSelectedList.push(item);
         }
       });
       // 判断当前 猪舍 是否需要清除
       let pigsty = this.pigstyByYid(this.form.pigstyId);
-      if (pigsty && pigsty.pastureId !== val) {
+      if (pigsty && pigsty.farmId !== val) {
         this.form.pigstyId = "";
       }
       /** 关于单元 */
       //  → 限制单元
       this.unSelectedList = [];
       this.unitList.forEach((item) => {
-        if (item.pastureId === val) {
+        if (item.farmId === val) {
           this.unSelectedList.push(item);
         }
       });
       // 判断当前 单元 是否需要清除
       let unit = this.UnitByIid(this.form.unitId);
-      if (unit && unit.pastureId !== val) {
+      if (unit && unit.farmId !== val) {
         this.form.unitId = "";
       }
       /** 关于栏期 */
       //  → 限制栏期
       this.peSelectedList = [];
       this.periodList.forEach((item) => {
-        if (item.pastureId === val) {
+        if (item.farmId === val) {
           this.peSelectedList.push(item);
         }
       });
       // 判断当前 栏期 是否需要清除
       let period = this.periodByJid(this.form.periodId);
-      if (period && period.pastureId !== val) {
+      if (period && period.farmId !== val) {
         this.form.periodId = "";
       }
     },
@@ -809,9 +814,9 @@ export default {
     getPigsty(val) {
       //  → 反向确定牧场
       let pigsty = this.pigstyByYid(this.form.pigstyId);
-      this.form.pastureId = pigsty.pastureId;
+      this.form.farmId = pigsty.farmId;
       // → 先获取猪舍,没有确定牧场的情况下,限制猪舍自身
-      this.phSelectedList = this.xidYlist(pigsty.pastureId);
+      this.phSelectedList = this.xidYlist(pigsty.farmId);
       /** 关于单元 */
       // → 限制单元
       this.unSelectedList = [];
@@ -843,10 +848,10 @@ export default {
     getUnit(val) {
       let unit = this.UnitByIid(val);
       // 反向确定 牧场 + 猪舍
-      this.form.pastureId = unit.pastureId;
+      this.form.farmId = unit.farmId;
       this.form.pigstyId = unit.pigstyId;
       // 反向确定 猪舍selectedList + 单元selectedList + 栏期selectedList
-      this.phSelectedList = this.xidYlist(unit.pastureId);
+      this.phSelectedList = this.xidYlist(unit.farmId);
       this.unSelectedList = this.yidIlist(unit.pigstyId);
       this.peSelectedList = this.yidJlist(unit.pigstyId);
       // 判断当前栏期是否需要清除
@@ -856,10 +861,10 @@ export default {
       }
     },
     // 根据牧场id → 限制猪舍selectedList
-    xidYlist(pastureId) {
+    xidYlist(farmId) {
       let phSelectedList = [];
       this.pighouseList.forEach((item) => {
-        if (item.pastureId === pastureId) {
+        if (item.farmId === farmId) {
           phSelectedList.push(item);
         }
       });
@@ -916,10 +921,10 @@ export default {
     getPeriod(val) {
       let period = this.periodByJid(val);
       // 反向确定牧场 + 猪舍
-      this.form.pastureId = period.pastureId;
+      this.form.farmId = period.farmId;
       this.form.pigstyId = period.pigstyId;
       // 反向确定 猪舍selectedList + 单元selectedList + 栏期selectedList
-      this.phSelectedList = this.xidYlist(period.pastureId);
+      this.phSelectedList = this.xidYlist(period.farmId);
       this.unSelectedList = this.yidIlist(period.pigstyId);
       this.peSelectedList = this.yidJlist(period.pigstyId);
       // 判断当前 单元 是否需要清除
@@ -1199,7 +1204,7 @@ export default {
     },
   },
   components: {
-    pbbasicLeft,
+    // pbbasicLeft,
   },
 };
 </script>

+ 2 - 2
src/views/modules/pigbasic/pbbasicLeft.vue

@@ -86,7 +86,7 @@ export default {
     getDataList () {
       // 获取所有牧场
       this.$http({
-        url: this.$http.adornUrl("/management/pasture/findAll"),
+        url: this.$http.adornUrl("/management/farm/findAll"),
         method: "post"
       }).then(async ({ data }) => {
         // 获取所有猪舍
@@ -129,7 +129,7 @@ export default {
                 pitem.children.push(uitem)
               }
             })
-            if (pighouse.pastureId === pasture.id) {
+            if (pighouse.farmId === pasture.id) {
               item.children.push(pitem)
             }
           })

+ 7 - 5
src/views/modules/sys/department-add-or-update.vue

@@ -65,7 +65,7 @@
             label: '女'
           }
         ],
-        pastures: [], // 牧场select
+        // pastures: [], // 牧场select
         departments: [], // 部门select
         jobs: [], // 岗位select
         roleList: []
@@ -185,14 +185,16 @@
               })
             }).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')
-                  }
+                  // onClose: () => {
+                  //   this.visible = false
+                  //   this.$emit('refreshDataList')
+                  // }
                 })
                 this.visible = false
               } else {

+ 6 - 4
src/views/modules/sys/job-add-or-update.vue

@@ -112,14 +112,16 @@
               })
             }).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')
-                  }
+                  // onClose: () => {
+                  //   this.visible = false
+                  //   this.$emit('refreshDataList')
+                  // }
                 })
               } else {
                 this.$message.error(data.msg)

+ 6 - 4
src/views/modules/sys/menu-add-or-update.vue

@@ -210,14 +210,16 @@
               })
             }).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')
-                  }
+                  // onClose: () => {
+                  //   this.visible = false
+                  //   this.$emit('refreshDataList')
+                  // }
                 })
               } else {
                 this.$message.error(data.msg)

+ 5 - 5
src/views/modules/sys/pasture.vue

@@ -255,7 +255,7 @@ export default {
     getDataList () {
       this.dataListLoading = true
       this.$http({
-        url: this.$http.adornUrl('/management/pasture/list'),
+        url: this.$http.adornUrl('/management/farm/list'),
         method: 'post',
         params: this.$http.adornParams({
           page: this.pageIndex,
@@ -341,7 +341,7 @@ export default {
           return
         }
         this.$http({
-          url: this.$http.adornUrl('/management/pasture/delete'),
+          url: this.$http.adornUrl('/management/farm/delete'),
           method: 'post',
           data: this.$http.adornData(this.selectionDataList, false)
         }).then(result => {
@@ -387,7 +387,7 @@ export default {
         }
         // 进行修改操作
         this.$http({
-          url: this.$http.adornUrl('/management/pasture/update'),
+          url: this.$http.adornUrl('/management/farm/update'),
           method: 'post',
           data: this.$http.adornData({
             id: this.form.id,
@@ -436,7 +436,7 @@ export default {
         }
         // 进行新增操作
         this.$http({
-          url: this.$http.adornUrl('/management/pasture/save'),
+          url: this.$http.adornUrl('/management/farm/save'),
           method: 'post',
           data: this.$http.adornData({
             location: this.form.location,
@@ -602,7 +602,7 @@ export default {
   }
 }
 </script>
-<style>
+<style scoped>
 .rect {
   background-color: #fff;
   padding: 30px 15px;

+ 6 - 4
src/views/modules/sys/role-add-or-update.vue

@@ -110,14 +110,16 @@
               })
             }).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')
-                  }
+                  // onClose: () => {
+                  //   this.visible = false
+                  //   this.$emit('refreshDataList')
+                  // }
                 })
               } else {
                 this.$message.error(data.msg)

+ 35 - 16
src/views/modules/sys/user-add-or-update.vue

@@ -1,6 +1,6 @@
 <template>
   <el-dialog
-    :title="!dataForm.id ? '新增' : '修改'"
+    :title="!dataForm.userId ? '新增' : '修改'"
     :close-on-click-modal="false"
     :visible.sync="visible"
     width="600px">
@@ -15,6 +15,9 @@
       <el-form-item label="姓名" prop="username">
         <el-input v-model="dataForm.username"></el-input>
       </el-form-item>
+      <el-form-item v-if="!dataForm.userId" label="密码" prop="password">
+        <el-input v-model="dataForm.password"></el-input>
+      </el-form-item>
       <el-form-item label="性别" prop="sex">
         <el-select 
           v-model="dataForm.sex"
@@ -125,7 +128,14 @@
   export default {
     data () {
       var validateEmail = (rule, value, callback) => {
-        if (!isEmail(value)) {
+        // if (!isEmail(value)) {
+        //   callback(new Error('邮箱格式错误'))
+        // } else {
+        //   callback()
+        // }
+        if (value === '') {
+          callback()
+        } else if (!isEmail(value)) {
           callback(new Error('邮箱格式错误'))
         } else {
           callback()
@@ -147,6 +157,7 @@
         // },
         dataForm: {
           userId: 0,
+          password: '',
           username: '',
           sex: '',
           birthday: '',
@@ -164,37 +175,41 @@
           username: [
             { required: true, message: '姓名不能为空', trigger: 'blur' }
           ],
+          password: [
+            { required: true, message: '密码不能为空', trigger: 'blur' },
+            { min: 1, max: 20, message: '长度在 1 到 20 个字符之间', trigger: ['blur', 'change'] }
+          ],
           sex: [
             { required: true, message: '性别不能为空', trigger: 'blur' }
           ],
           birthday: [
-            { required: true, message: '出生日期不能为空', trigger: 'blur' }
+            // { required: true, message: '出生日期不能为空', trigger: 'blur' }
           ],
           mobile: [
             { required: true, message: '手机号码不能为空', trigger: 'blur' },
             { validator: validateMobile, trigger: 'blur' }
           ],
           email: [
-            { required: true, message: '邮箱不能为空', trigger: 'blur' },
+            // { required: true, message: '邮箱不能为空', trigger: 'blur' },
             { validator: validateEmail, trigger: 'blur' }
           ],
           farmId: [
-            { required: true, message: '牧场不能为空', trigger: 'blur' }
+            // { required: true, message: '牧场不能为空', trigger: 'blur' }
           ],
           departmentCode: [
-            { required: true, message: '部门不能为空', trigger: 'blur' }
+            // { required: true, message: '部门不能为空', trigger: 'blur' }
           ],
           jobCode: [
-            { required: true, message: '岗位不能为空', trigger: 'blur' }
+            // { required: true, message: '岗位不能为空', trigger: 'blur' }
           ],
           address: [
-            { required: true, message: '住址不能为空', trigger: 'blur' }
+            // { required: true, message: '住址不能为空', trigger: 'blur' }
           ],
           roleIdList: [
-            { required: true, message: '角色不能为空', trigger: 'blur' }
+            // { required: true, message: '角色不能为空', trigger: 'blur' }
           ],
           status: [
-            { required: true, message: '状态不能为空', trigger: 'blur' }
+            // { required: true, message: '状态不能为空', trigger: 'blur' }
           ]
         },
         tempKey: -666666, // 临时key, 用于解决tree半选中状态项不能传给后台接口问题. # 待优化
@@ -235,9 +250,9 @@
           this.$refs['dataForm'].resetFields()
         })
         // 在role.vue调用该方法
-        this.dataForm.userId = userId || 0
+        this.dataForm.userId = userId || undefined
         this.$http({
-          url: this.$http.adornUrl("/management/pasture/findAll"),
+          url: this.$http.adornUrl("/management/farm/findAll"),
           method: "post"
         }).then(async({ data }) => {
           // 牧场select
@@ -362,6 +377,7 @@
       // 表单提交
       dataFormSubmit () {
         this.$refs['dataForm'].validate((valid) => {
+          console.log(valid);
           if (valid) {
             this.$http({
               url: this.$http.adornUrl(`/sys/user/${!this.dataForm.userId ? 'save' : 'update'}`),
@@ -369,6 +385,7 @@
               data: this.$http.adornData({
                 'userId': this.dataForm.userId || undefined,
                 'username': this.dataForm.username,
+                'password': this.dataForm.password,
                 'sex': this.dataForm.sex,
                 'birthday': this.dataForm.birthday,
                 'mobile': this.dataForm.mobile,
@@ -385,14 +402,16 @@
               })
             }).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')
-                  }
+                  // onClose: () => {
+                  //   this.visible = false
+                  //   this.$emit('refreshDataList')
+                  // }
                 })
                 // this.resetForm()
                 this.visible = false

+ 1 - 1
src/views/modules/sys/user-left.vue

@@ -44,7 +44,7 @@ export default {
     getDataList () {
       // 获取所有牧场
       this.$http({
-        url: this.$http.adornUrl("/management/pasture/findAll"),
+        url: this.$http.adornUrl("/management/farm/findAll"),
         method: "post"
       }).then(async ({ data }) => {
         /* 不需要猪舍和单元 */

+ 1 - 1
src/views/modules/sys/user.vue

@@ -150,7 +150,7 @@
                 label="部门">
               </el-table-column>
               <el-table-column
-                prop="pastureName"
+                prop="farmName"
                 header-align="center"
                 align="center"
                 width="140"