Forráskód Böngészése

主牧场模块页面

Shan9312 1 hónapja
szülő
commit
89cc11a071
3 módosított fájl, 502 hozzáadás és 12 törlés
  1. 19 1
      src/api/common.js
  2. 11 11
      src/router/index.js
  3. 472 0
      src/views/basic/ranchAccompany/index.vue

+ 19 - 1
src/api/common.js

@@ -381,4 +381,22 @@ export function saveImgIds(data) {
     method: 'post',
     data
   })
-}
+}
+
+// 主牧场修改
+export function editMainPasture(data) {
+  return request({
+    url: '/authdata/mainpasture/edit',
+    method: 'post',
+    data
+  })
+}
+
+// 查询主牧场
+export function getMainPastur(data) {
+  return request({
+    url: '/authdata/mainpasture/list',
+    method: 'get',
+    params: data
+  })
+}

+ 11 - 11
src/router/index.js

@@ -67,17 +67,17 @@ export const constantRoutes = [
     }]
   },
 
-  // {
-  //   path: '/spotCheck',
-  //   component: Layout,
-  //   redirect: '/spotCheck',
-  //   children: [{
-  //     path: 'spotCheck',
-  //     name: 'spotCheck',
-  //     component: () => import('@/views/report/spotCheck/index.vue'),
-  //     meta: { title: '点检率', icon: '', affix: true }
-  //   }]
-  // }
+  {
+    path: '/ranchAccompany',
+    component: Layout,
+    redirect: '/ranchAccompany',
+    children: [{
+      path: 'ranchAccompany',
+      name: 'ranchAccompany',
+      component: () => import('@/views/basic/ranchAccompany/index.vue'),
+      meta: { title: '主牧场配置', icon: '', affix: true }
+    }]
+  }
 
   // {
   //   path: '/vehiclRateTotal',

+ 472 - 0
src/views/basic/ranchAccompany/index.vue

@@ -0,0 +1,472 @@
+<template>
+  <div class="app-container">
+    <div class="app-container">
+      <div class="filter-container">
+        <el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="form_add"> 新增 </el-button>
+      </div>
+      <el-table
+        v-loading="listLoading"
+        element-loading-text="给我一点时间"
+        :data="list"
+        border
+        fit
+        highlight-current-row
+        style="width: 100%;"
+        :row-style="rowStyle"
+        :cell-style="cellStyle"
+        class="elTable"
+        row-key="id"
+        :tree-props="{children: 'list'}"
+        :max-height="myHeight"
+      >
+        <el-table-column label="序号" type="index" width="50" />
+        <el-table-column label="牧场名称" header-align="center" min-width="150px">
+          <template slot-scope="scope">
+            <span>{{ scope.row.name }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column label="牧场编号" header-align="center" min-width="110px">
+          <template slot-scope="scope">
+            <span>{{ scope.row.pastureNumber }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column label="说明" min-width="150px" align="center">
+          <template slot-scope="scope">
+            <span>{{ scope.row.remark }}</span>
+          </template>
+        </el-table-column>
+
+        <el-table-column label="操作" align="center" width="260" class-name="small-padding fixed-width" fixed="right">
+          <template slot-scope="{row}">
+            <el-button type="primary" size="mini" @click="form_edit(row,1)"> 编辑 </el-button>
+            <el-button v-if="row.status!='已删'" size="mini" type="danger" @click="form_edit(row,2)"> 删除 </el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+
+      <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" :close-on-click-modal="false">
+        <el-form ref="dataForm" :rules="rules" :model="deptform" label-position="left" label-width="100px" style="width: 50%; margin-left:50px;">
+          <el-form-item  label="上级层级:" prop="mainPastrue">
+            <tree-select
+              :disabled="disabled"
+              :height="300"
+              :width="300"
+              size="small"
+              :data="parentDept"
+              :default-props="defaultProps"
+              :node-key="nodeKey"
+              :checked-keys="defaultCheckedKeys"
+              @popoverHide="popoverHide"
+              :clearable="true"
+            />
+          </el-form-item>
+          <el-form-item label="牧场名称:" prop="pastureId"  >
+            <el-select v-model="deptform.pastureId" placeholder="牧场:"  @change="getCode" >
+              <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.id" />
+            </el-select>
+          </el-form-item>
+          <!-- <el-form-item label="牧场名称:" prop="pastureId" v-else >
+            <el-input
+              ref="pastureNumber"
+              v-model="deptform.pastureName"
+              placeholder="牧场名称"
+              disabled
+            />
+          </el-form-item> -->
+          <el-form-item label="牧场编号:" prop="pastureNumber">
+            <el-input
+              ref="pastureNumber"
+              v-model="deptform.pastureNumber"
+              placeholder="自动填入编号"
+              disabled
+            />
+          </el-form-item>
+
+
+          <el-form-item label="说明: " prop="remark">
+            <el-input
+              ref="remark"
+              v-model="deptform.remark"
+              :autosize="{ minRows: 2, maxRows: 4}"
+              type="textarea"
+              placeholder="请输入"
+            />
+          </el-form-item>
+
+        </el-form>
+        <div slot="footer" class="dialog-footer">
+          <!-- <el-button v-if="dialogStatus==='create'" ref="createb" type="success" @click="add_dialog_save_again()"> 确认新增 </el-button> -->
+          <el-button type="primary" @click="form_addConfirm('提交成功')"> 确认提交 </el-button>
+          <el-button @click="dialogFormVisible = false;get_table_data()"> 关闭 </el-button>
+        </div>
+      </el-dialog>
+    </div>
+  </div>
+</template>
+
+<script>
+import TreeSelect from '@/components/TreeSelect'
+import waves from '@/directive/waves' // waves directive
+import { isIntegerZero } from '@/utils/validate'
+import { PostDataByName, editMainPasture,getMainPastur, GetDataByName, transData, failproccess ,GetDataByNames} from '@/api/common'
+import { MessageBox } from 'element-ui'
+import Cookies from 'js-cookie'
+
+export default {
+  name: 'Dept',
+  components: { TreeSelect },
+  directives: { waves },
+  data() {
+    return {
+      myHeight:document.documentElement.clientHeight - 85- 150,
+      disabled: false,
+      tableKey: 0,
+      list: [],
+      findAllPasture: [],
+      parentDept: [],
+      listLoading: true,
+      requestParam: {
+        name: 'createdept'
+      },
+      requestParamDel: {},
+      deptform: {
+        remark: '',
+        mainPastrue: '',
+        isMain:"",
+        pastureId:""
+      },
+     requestParams: [{ name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: {'id': Cookies.get('pastureid') }},
+      ],
+     requestParams1: [{ name: 'getPastureIsMain', offset: 0, pagecount: 0, returntype: 'Map', parammaps: {  }},
+    ],
+      getDeptListParm: { name: 'getdeptlistrecu',
+        idname: 'id',
+        params: [-1] },
+      getDeptParm: { name: 'getdeptrecu',
+        idname: 'value',
+        params: [-1] },
+      getDepartListParm: { name: 'getalldeptname' },
+      rules: {
+        pastureName: [{  required: true, message: '牧场名称必填', trigger: 'blur' }],
+        mainPastrue: [{ required: true, message: '上层级名称必填', trigger: 'blur' }]
+      },
+      dialogFormVisible: false,
+      parentDeptVisible: true,
+      dialogStatus: '',
+      textMap: {
+        update: '编辑',
+        create: '新增'
+      },
+      rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
+      cellStyle: { padding: 0 + 'px' },
+      defaultProps: {
+        children: 'list',
+        label: 'name'
+      },
+      nodeKey: 'id',
+      defaultCheckedKeys: [],
+      type: '',
+      mainPastrue:[]
+    }
+  },
+  created() {
+    this.get_table_data()
+    this.get_select_list()
+
+  },
+  methods: {
+    // 编号
+    getCode(val) {
+      const obj = this.findAllPasture.find((item) => { return item.id == val })
+      console.log(obj,'obj')
+      this.deptform.pastureNumber = obj.pastureNumber;
+      this.deptform.pastureName = obj.name;
+      // this.dataform.pastureId = obj.id;
+    },
+    // 牧场
+     get_select_list() {
+      GetDataByNames(this.requestParams).then(response => {
+        this.findAllPasture = response.data.findAllPasture.list
+        console.log(this.findAllPasture,'hss')
+      })
+    },
+
+    get_mainPas_list() {
+      GetDataByNames(this.requestParams1).then(response => {
+        this.parentDept = response.data.getPastureIsMain.list
+        //  this.parentDept = this.list
+        console.log(  this.parentDept,response.data,'0++++')
+      })
+    },
+
+    popoverHide(checkedIds, checkedData) {
+      console.log(checkedIds, checkedData)
+      this.deptform.mainPastrue = checkedIds
+      // this.deptform.pastureId = checkedData.pastureId
+    },
+    deptenter() {
+      this.$nextTick(() => {
+        this.$refs['remark'].focus()
+      })
+    },
+    get_table_data() {
+      this.listLoading = true
+      getMainPastur().then(response => {
+        if (response.data.list !== null) {
+          this.list = transData(response.data, 'id', 'list')
+        }
+        setTimeout(() => {
+          this.listLoading = false
+        }, 10)
+      })
+      this.get_mainPas_list()
+    },
+    // getDeptList() {
+    //   getRecuData(this.getDeptParm).then(response => {
+    //     this.parentDept = response.data
+    //   })
+    // },
+    resetRequestParam() {
+      this.deptform.isMain = ''
+      this.deptform.mainPastrue = ''
+      this.deptform.pastureId = ''
+      this.deptform.remark = ''
+      this.deptform.pastureName = ''
+      this.deptform.pastureNumber = ''
+    },
+    form_add() {
+      this.resetRequestParam()
+      this.dialogStatus = 'create'
+      this.parentDeptVisible = true
+      this.dialogFormVisible = true
+      if (this.list.length > 0) {
+        this.defaultCheckedKeys = [this.list[0].id]
+        this.deptform.mainPastrue = this.list[0].id
+        // this.deptform.pastureId = this.list[0].id
+      } else {
+        this.deptform.mainPastrue = 0
+      }
+      // this.$nextTick(() => {
+      //   this.$refs['dataForm'].clearValidate()
+      // })
+    },
+    // add_dialog_save() {
+    //   this.$refs['dataForm'].validate((valid) => {
+    //     if (valid) {
+    //       this.requestParam.name = 'createdept'
+    //       this.requestParam.parammaps = {}
+    //       this.requestParam.parammaps.pastureNumber = this.deptform.pastureNumber
+    //       this.requestParam.parammaps.KCcode = this.deptform.KCcode
+    //       this.requestParam.parammaps.pastureId = this.deptform.pastureId
+    //       this.requestParam.parammaps.mainPastrue = this.deptform.mainPastrue
+    //       this.requestParam.parammaps.deptname = this.deptform.deptname
+    //       this.requestParam.parammaps.remark = this.deptform.remark
+    //       this.requestParam.parammaps.sort = this.deptform.sort
+    //       this.requestParam.parammaps.enable = this.deptform.enable
+    //       this.requestParam.parammaps.isPasture = this.deptform.isPasture
+    //       this.requestParam.parammaps.costCenter_code = this.deptform.costCenter_code
+    //       PostDataByName(this.requestParam).then(response => {
+    //         if (response.msg !== 'fail') {
+    //           this.get_table_data()
+    //           this.dialogFormVisible = false
+    //           this.$notify({
+    //             title: '成功',
+    //             message: '新增成功',
+    //             type: 'success',
+    //             duration: 2000
+    //           })
+    //         } else {
+    //           failproccess(response, this.$notify)
+    //         }
+    //       })
+    //     }
+    //   })
+    // },
+    // add_dialog_save_again() {
+    //   this.$refs['dataForm'].validate((valid) => {
+    //     if (valid) {
+    //       this.requestParam.name = 'createdept'
+    //       this.requestParam.parammaps = {}
+    //       this.requestParam.parammaps.pastureNumber = this.deptform.pastureNumber
+    //       this.requestParam.parammaps.KCcode = this.deptform.KCcode
+    //       this.requestParam.parammaps.pastureId = this.deptform.pastureId
+    //       this.requestParam.parammaps.mainPastrue = this.deptform.mainPastrue
+    //       this.requestParam.parammaps.deptname = this.deptform.deptname
+    //       this.requestParam.parammaps.remark = this.deptform.remark
+    //       this.requestParam.parammaps.sort = this.deptform.sort
+    //       this.requestParam.parammaps.enable = this.deptform.enable
+    //       this.requestParam.parammaps.isPasture = this.deptform.isPasture
+    //       this.requestParam.parammaps.costCenter_code = this.deptform.costCenter_code
+    //       PostDataByName(this.requestParam).then(() => {
+    //         this.$nextTick(() => {
+    //           this.$refs['deptname'].focus()
+    //         })
+    //         this.get_table_data()
+    //         this.requestParam = {
+    //           name: 'createdept',
+    //           params: []
+    //         }
+    //         this.deptform.id = ''
+    //         this.deptform.deptname = ''
+    //         this.deptform.remark = ''
+    //         this.deptform.costCenter_code = ''
+    //         this.deptform.sort = '0'
+    //         this.deptform.enable = '1'
+    //         this.deptform.isPasture = '0'
+
+    //         this.$notify({
+    //           title: '成功',
+    //           message: '新增成功',
+    //           type: 'success',
+    //           duration: 2000
+    //         })
+    //       })
+    //     }
+    //   })
+    // },
+    form_addConfirm(type) {
+      if (this.type != 'del') {
+        // 如果 主牧场 和 子牧场 相同 ,则 isMain =1;
+         this.deptform.isMain = (this.deptform.mainPastrue &&  this.deptform.mainPastrue !== this.deptform.pastureId )? 0 : 1
+         this.deptform.mainPastrue = this.deptform.isMain == 1 ? 0 : this.deptform.mainPastrue
+       }
+      editMainPasture(this.deptform).then((res) => {
+        const { data } = res;
+        if (data == true) {
+          this.$notify({
+            title: '提示',
+            message: type,
+            type: 'success',
+            duration: 2000
+          })
+        } else {
+          this.$notify({
+            title: '提示',
+            message: data,
+            type: 'success',
+            duration: 2000
+          })
+        }
+       this.get_table_data()
+       this.dialogFormVisible = false
+       this.type = '';
+
+      })
+
+    },
+    form_edit(row, type) {
+      console.log(row,type,'000')
+      if (type != 1) {
+        this.type = 'del';
+        this.$confirm('此操作将永久删除牧场配置, 是否继续?', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          this.resetRequestParam()
+          this.deptform.isMain = 0
+          this.deptform.mainPastrue = 0
+          this.deptform.pastureId = row.id
+          this.form_addConfirm('删除成功')
+
+        }).catch(() => {
+          this.$message({
+            type: 'info',
+            message: '已取消删除'
+          });
+        });
+      } else {
+        this.type = 'edit';
+        this.deptform.pastureId = row.id
+        this.deptform.pastureName = row.name
+        this.deptform.pastureNumber = row.pastureNumber
+        this.deptform.remark = row.remark
+        this.deptform.mainPastrue = 0
+        this.dialogStatus = 'update'
+        this.dialogFormVisible = true
+        this.parentDeptVisible = true
+        // this.$nextTick(() => {
+        //   this.$refs['dataForm'].clearValidate()
+        //   this.$refs['deptname'].focus()
+        // })
+          console.log(this.deptform,'001')
+      }
+    },
+    edit_dialog_save() {
+      this.$refs['dataForm'].validate((valid) => {
+        if (valid) {
+          this.requestParam.name = 'updatedept'
+          this.requestParam.params = []
+          this.requestParam.params[0] = this.deptform.pastureNumber
+          this.requestParam.params[1] = this.deptform.KCcode
+          this.requestParam.params[2] = this.deptform.mainPastrue
+          this.requestParam.params[3] = this.deptform.deptname
+          this.requestParam.params[4] = this.deptform.remark
+          this.requestParam.params[5] = this.deptform.sort
+          this.requestParam.params[6] = this.deptform.enable
+          this.requestParam.params[7] = this.deptform.isPasture
+          this.requestParam.params[8] = this.deptform.costCenter_code
+          this.requestParam.params[9] = this.deptform.id
+
+          PostDataByName(this.requestParam).then(() => {
+            this.get_table_data()
+            this.dialogFormVisible = false
+            this.$notify({
+              title: '成功',
+              message: '修改成功',
+              type: 'success',
+              duration: 2000
+            })
+          })
+        }
+      })
+    },
+    handleEnableChange(index, row) {
+      this.requestParam.name = 'updatedept'
+      this.requestParam.params = []
+      if (row.sort === null) {
+        row.sort = '0'
+      }
+      this.requestParam.params[0] = row.pastureNumber
+      this.requestParam.params[1] = row.KCcode
+      this.requestParam.params[2] = row.mainPastrue
+      this.requestParam.params[3] = row.deptname
+      this.requestParam.params[4] = row.remark
+      this.requestParam.params[5] = row.sort
+      this.requestParam.params[6] = row.enable
+      this.requestParam.params[7] = row.isPasture
+      this.requestParam.params[8] = row.costCenter_code
+          this.requestParam.params[9] = row.id
+      PostDataByName(this.requestParam).then(() => {
+        this.$notify({
+          title: '成功',
+          message: '修改成功',
+          type: 'success',
+          duration: 2000
+        })
+      })
+    },
+    form_delete(row) {
+      MessageBox.confirm('部门名称:' + row.deptname, '确认删除?', {
+        confirmButtonText: '确认',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        this.requestParamDel.name = 'deletedept'
+        this.requestParamDel.params = []
+        this.requestParamDel.params[0] = row.id
+        PostDataByName(this.requestParamDel).then(() => {
+          this.get_table_data()
+          this.dialogFormVisible = false
+          this.$notify({
+            title: '成功',
+            message: '删除成功',
+            type: 'success',
+            duration: 2000
+          })
+        })
+      })
+    }
+  }
+}
+</script>