123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364 |
- <template>
- <div class="app-container">
- <div class="filter-container">
- <el-select v-model="table.getdataListParm.parammaps.pastureName" placeholder="牧场" style="width: 140px;" class="filter-item">
- <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
- </el-select>
- <el-button class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>
- </div>
- <div class="app-operation" style="height:50px">
- <el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="form_add">新增</el-button>
- </div>
- <div class="table">
- <el-table
- :key="table.tableKey"
- v-loading="table.listLoading"
- element-loading-text="给我一点时间"
- :data="table.list"
- border
- fit
- highlight-current-row
- style="width: 100%;"
- :row-style="rowStyle"
- :cell-style="cellStyle"
- class="elTable"
- :max-height="myHeight"
- >
- <el-table-column label="序号" align="center" type="index" width="50px">
- <template slot-scope="scope">
- <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
- </template>
- </el-table-column>
- <el-table-column label="中心" min-width="150px" align="center" prop="center" />
- <el-table-column label="区域" min-width="150px" align="center" prop="areaName" />
- <el-table-column label="牧场" min-width="150px" align="center" prop="pastureName" />
- <el-table-column label="牧场全称" min-width="150px" align="center" prop="companyName" />
- <el-table-column label="牧场编号" min-width="150px" align="center" prop="pastureNumber" />
- <el-table-column label="地图经度" min-width="150px" align="center" prop="longitude" />
- <el-table-column label="地图纬度" min-width="150px" align="center" prop="latitude" />
- <el-table-column label="供应负责人" min-width="150px" align="center" prop="empname" />
- <el-table-column label="负责人电话" min-width="150px" align="center" prop="tel" />
- <el-table-column label="备注" min-width="150px" align="center" prop="note" />
- <el-table-column label="顺序" min-width="150px" align="center" prop="sort" />
- <el-table-column label="操作" align="center" width="230" class-name="small-padding fixed-width" fixed="right">
- <template slot-scope="{row}">
- <el-button type="primary" size="mini" @click="form_see(row)">查看</el-button>
- <el-button type="success" size="mini" @click="form_edit(row)">编辑</el-button>
- </template>
- </el-table-column>
- </el-table>
- <pagination v-show="table.total>0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="get_table_data" />
- </div>
- <div class="create">
- <el-dialog :title="textMap[create.dialogStatus]" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="40%">
- <el-form ref="createTemp" :rules="create.rules" :model="create.temp" label-position="right" label-width="110px" style="width: 80%;margin: 0 auto;">
- <el-row>
- <el-col :span="24">
- <el-form-item label="所属区域:" prop="areaId" v-if="create.dialogStatus =='create'">
- <el-select v-model="create.temp.areaId" placeholder="所属区域" style="width: 100%;">
- <el-option v-for="item in regionList" :key="item.id" :label="item.name" :value="item.id" />
- </el-select>
- </el-form-item>
- <el-form-item label="所属区域:" v-else>
- <!-- <el-input ref="areaName" v-model="create.temp.areaName" placeholder="所属区域" style="width: 100%;" /> -->
- <el-select v-model="create.temp.areaid" placeholder="所属区域" style="width: 100%;" :disabled="create.dialogStatus =='see'" >
- <el-option v-for="item in regionList" :key="item.id" :label="item.name" :value="parseInt(item.id)" />
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="24">
- <el-form-item label="牧场:" prop="pastureName">
- <el-input ref="pastureName" v-model="create.temp.pastureName" placeholder="牧场" style="width: 100%;" :disabled="create.dialogStatus =='see'" /><!-- :disabled="create.dialogStatus =='see'" -->
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="24">
- <el-form-item label="牧场全称:" prop="companyName">
- <el-input ref="companyName" v-model="create.temp.companyName" placeholder="牧场全称" style="width: 100%;" :disabled="create.dialogStatus =='see'" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="24">
- <el-form-item label="牧场编号:" prop="pastureNumber">
- <el-input ref="pastureNumber" v-model="create.temp.pastureNumber" placeholder="牧场编号" style="width: 100%;" :disabled="create.dialogStatus =='see'" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="24">
- <el-form-item label="中心: " prop="center">
- <el-input ref="center" v-model="create.temp.center" placeholder="中心" style="width: 100%;" :disabled="create.dialogStatus =='see'" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="24">
- <el-form-item label="地图经度:" prop="longitude">
- <el-input ref="longitude" v-model="create.temp.longitude" type="number" placeholder="请输入数字" :disabled="create.dialogStatus =='see'" style="width: 100%;" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="24">
- <el-form-item label="地图纬度:" prop="latitude">
- <el-input ref="latitude" v-model="create.temp.latitude" type="number" placeholder="请输入数字" :disabled="create.dialogStatus =='see'" style="width: 100%;" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="24">
- <el-form-item label="供应负责人:" prop="empId">
- <el-select v-model="create.temp.empId" filterable placeholder="供应负责人" style="width: 100%;" :disabled="create.dialogStatus =='see'" @change="changeEmp">
- <el-option v-for="item in findAllEmploye" :key="item.id" :label="item.name" :value="item.id" />
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="24">
- <el-form-item label="负责人电话:" prop="tel">
- <el-input ref="tel" v-model="create.temp.tel" disabled style="width: 100%;" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row>
- <el-col :span="24">
- <el-form-item label="备注:" prop="note">
- <el-input ref="note" v-model="create.temp.note" placeholder="备注" :disabled="create.dialogStatus =='see'" style="width: 100%;" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row v-if="create.dialogStatus !=='create'">
- <el-col :span="24">
- <el-form-item label="顺序:" prop="sort">
- <el-input ref="sort" v-model="create.temp.sort" type="number" placeholder="顺序" :disabled="create.dialogStatus =='see'" style="width: 100%;" />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button v-if="create.dialogStatus !== 'see'" :disabled="isokDisable" type="primary" @click="create.dialogStatus =='create'?add_dialog_save():edit_dialog_save()">保存并关闭</el-button>
- <el-button @click="create.dialogFormVisible = false;get_table_data()">关闭</el-button>
- </div>
- </el-dialog>
- </div>
- </div>
- </template>
- <script>
- import { GetDataByName, GetDataByNames, ExecDataByConfig } from '@/api/common'
- import Pagination from '@/components/Pagination'
- import { MessageBox } from 'element-ui'
- import Cookies from 'js-cookie'
- export default {
- name: 'RanchManagement',
- components: { Pagination },
- data() {
- return {
- myHeight:document.documentElement.clientHeight - 85- 200,
- requestParams: [
- { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }},
- { name: 'getareaList', offset: 0, pagecount: 0, returntype: 'Map', parammaps: {}},
- { name: 'findAllEmploye', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }},
- ],
- findAllPasture: [],
- findAllEmploye: [],
- regionList: [], // 所属区域
- areaIds:[],
- table: {
- tableKey: 0,
- list: null,
- total: 0,
- listLoading: true,
- getdataListParm: {
- name: 'getPastureInforList',
- page: 1,
- offset: 1,
- pagecount: 10,
- returntype: 'Map',
- parammaps: {}
- }
- },
- create: {
- dialogFormVisible: false,
- dialogStatus: '',
- rules: {
- areaId: [{ required: true, message: '必填', trigger: 'blur' }],
- pastureName: [{ required: true, message: '必填', trigger: 'blur' }],
- companyName: [{ required: true, message: '必填', trigger: 'blur' }],
- pastureNumber: [{ required: true, message: '必填', trigger: 'blur' }]
- },
- temp: {
- areaId: '', pastureName: '', pastureNumber: '', longitude: '', latitude: '', note: '', sort: '',center:'',empId:'',tel:''
- }
- },
- postDataParam: {},
- textMap: { create: '新增', update: '编辑', see: '查看' },
- isokDisable: false,
- rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
- cellStyle: { padding: 0 + 'px' }
- }
- },
- created() {
- this.get_select_list()
- this.get_table_data()
- },
- methods: {
- get_select_list() {
- GetDataByNames(this.requestParams).then(response => {
- this.findAllPasture = response.data.findAllPasture.list
- this.regionList = response.data.getareaList.list
- this.findAllEmploye = response.data.findAllEmploye.list
- this.regionList.forEach(row => {
- this.areaIds[row.id]= row.name
- });
- })
- },
- get_table_data() {
- this.table.listLoading = true
- GetDataByName(this.table.getdataListParm).then(response => {
- this.table.list = response.data.list
- this.table.pageNum = response.data.pageNum
- this.table.pageSize = response.data.pageSize
- if (response.data.total) {
- this.table.total = response.data.total
- }
- setTimeout(() => {
- this.table.listLoading = false
- }, 100)
- })
- },
- form_search() {
- this.table.getdataListParm.offset = 1
- this.get_table_data()
- },
- resetCreateTemp() {
- this.create.temp.areaId = ''
- this.create.temp.pastureName = ''
- this.create.temp.pastureNumber = ''
- this.create.temp.longitude = ''
- this.create.temp.latitude = ''
- this.create.temp.note = ''
- this.create.temp.sort = ''
- this.create.temp.center = ''
- this.create.temp.empId = ''
- this.create.temp.tel = ''
- },
- form_add() {
- this.resetCreateTemp()
- this.create.dialogStatus = 'create'
- this.create.dialogFormVisible = true
- this.$nextTick(() => {
- this.$refs['createTemp'].clearValidate()
- })
- },
- changeEmp(item){
- console.log(item)
- this.create.temp.tel = this.findAllEmploye.find(obj => obj.id == item).tel
- },
- add_dialog_save() {
- this.$refs['createTemp'].validate(valid => {
- if (valid) {
- this.isokDisable = true
- setTimeout(() => {
- this.isokDisable = false
- }, 1000)
- this.postDataParam.common = { 'returnmap': '0' }
- this.postDataParam.data = []
- this.postDataParam.data[0] = { 'name': 'insertPasture', 'type': 'e', 'parammaps': {
- pastureName: this.create.temp.pastureName,
- pastureNumber: this.create.temp.pastureNumber,
- longitude: this.create.temp.longitude,
- latitude: this.create.temp.latitude,
- note: this.create.temp.note,
- center:this.create.temp.center,
- companyName: this.create.temp.companyName,
- empId: this.create.temp.empId
- }}
- this.postDataParam.data[1] = { 'name': 'insertPastureDept', 'type': 'e', 'parammaps': {
- pastureName: this.create.temp.pastureName,
- pastureId: '@insertPasture.LastInsertId',
- areaId: this.create.temp.areaId
- }}
- ExecDataByConfig(this.postDataParam).then(response => {
- console.log('新增保存发送参数', this.postDataParam)
- if (response.msg === 'fail') {
- this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
- } else {
- this.create.dialogFormVisible = false
- this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
- this.get_table_data()
- }
- })
- }
- })
- },
- form_edit(row) {
- console.log(row)
- this.create.temp = Object.assign({}, row)
- this.create.dialogStatus = 'update'
- this.create.dialogFormVisible = true
- },
- edit_dialog_save() {
- this.$refs['createTemp'].validate(valid => {
- if (valid) {
- this.isokDisable = true
- setTimeout(() => {
- this.isokDisable = false
- }, 1000)
- this.postDataParam.common = { 'returnmap': '0' }
- this.postDataParam.data = []
- this.postDataParam.data[0] = { 'name': 'updatePastureDept', 'type': 'e', 'parammaps': {
- name:this.create.temp.pastureName,
- companyName:this.create.temp.companyName,
- pastureNumber:this.create.temp.pastureNumber,
- center:this.create.temp.center,
- region:this.areaIds[this.create.temp.areaid],
- longitude: this.create.temp.longitude,
- latitude: this.create.temp.latitude,
- note: this.create.temp.note,
- id: this.create.temp.id,
- sort: this.create.temp.sort,
- empId: this.create.temp.empId
- }}
- this.postDataParam.data[1] = { 'name': 'updateDepartment', 'type': 'e', 'parammaps': {
- dname: this.create.temp.pastureName,
- pastureId: this.create.temp.areaid,
- id: this.create.temp.id
- }}
- ExecDataByConfig(this.postDataParam).then(response => {
- console.log('编辑保存发送参数', this.postDataParam)
- if (response.msg === 'fail') {
- this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
- } else {
- this.create.dialogFormVisible = false
- this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
- this.get_table_data()
- }
- })
- }
- })
- },
- form_see(row) {
- this.create.dialogStatus = 'see'
- this.create.dialogFormVisible = true
- this.create.temp = Object.assign({}, row)
- }
- }
- }
- </script>
- <style>
- input::-webkit-outer-spin-button,
- input::-webkit-inner-spin-button {
- -webkit-appearance: none;
- }
- input[type="number"]{
- -moz-appearance: textfield;
- }
- </style>
|