index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container">
  4. <el-select v-model="table.getdataListParm.parammaps.pastureName" placeholder="牧场" style="width: 140px;" class="filter-item">
  5. <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
  6. </el-select>
  7. <el-button class="filter-item" type="primary" icon="el-icon-search" @click="form_search">搜索</el-button>
  8. </div>
  9. <div class="app-operation" style="height:50px">
  10. <el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="form_add">新增</el-button>
  11. </div>
  12. <div class="table">
  13. <el-table
  14. :key="table.tableKey"
  15. v-loading="table.listLoading"
  16. element-loading-text="给我一点时间"
  17. :data="table.list"
  18. border
  19. fit
  20. highlight-current-row
  21. style="width: 100%;"
  22. :row-style="rowStyle"
  23. :cell-style="cellStyle"
  24. class="elTable"
  25. >
  26. <el-table-column label="序号" align="center" type="index" width="50px">
  27. <template slot-scope="scope">
  28. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  29. </template>
  30. </el-table-column>
  31. <el-table-column label="区域" min-width="150px" align="center" prop="areaName" />
  32. <el-table-column label="牧场" min-width="150px" align="center" prop="pastureName" />
  33. <el-table-column label="牧场全称" min-width="150px" align="center" prop="companyName" />
  34. <el-table-column label="牧场编号" min-width="150px" align="center" prop="pastureNumber" />
  35. <el-table-column label="中心" min-width="150px" align="center" prop="center" />
  36. <el-table-column label="地图经度" min-width="150px" align="center" prop="longitude" />
  37. <el-table-column label="地图纬度" min-width="150px" align="center" prop="latitude" />
  38. <el-table-column label="备注" min-width="150px" align="center" prop="note" />
  39. <el-table-column label="顺序" min-width="150px" align="center" prop="sort" />
  40. <el-table-column label="操作" align="center" width="230" class-name="small-padding fixed-width" fixed="right">
  41. <template slot-scope="{row}">
  42. <el-button type="primary" size="mini" @click="form_see(row)">查看</el-button>
  43. <el-button type="success" size="mini" @click="form_edit(row)">编辑</el-button>
  44. </template>
  45. </el-table-column>
  46. </el-table>
  47. <pagination v-show="table.total>0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  48. </div>
  49. <div class="create">
  50. <el-dialog :title="textMap[create.dialogStatus]" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="40%">
  51. <el-form ref="createTemp" :rules="create.rules" :model="create.temp" label-position="right" label-width="110px" style="width: 80%;margin: 0 auto;">
  52. <el-row>
  53. <el-col :span="24">
  54. <el-form-item label="所属区域:" prop="areaId" v-if="create.dialogStatus =='create'">
  55. <el-select v-model="create.temp.areaId" placeholder="所属区域" style="width: 100%;">
  56. <el-option v-for="item in regionList" :key="item.id" :label="item.name" :value="item.id" />
  57. </el-select>
  58. </el-form-item>
  59. <el-form-item label="所属区域:" v-else>
  60. <!-- <el-input ref="areaName" v-model="create.temp.areaName" placeholder="所属区域" style="width: 100%;" /> -->
  61. <el-select v-model="create.temp.areaid" placeholder="所属区域" style="width: 100%;" :disabled="create.dialogStatus =='see'" >
  62. <el-option v-for="item in regionList" :key="item.id" :label="item.name" :value="parseInt(item.id)" />
  63. </el-select>
  64. </el-form-item>
  65. </el-col>
  66. </el-row>
  67. <el-row>
  68. <el-col :span="24">
  69. <el-form-item label="牧场:" prop="pastureName">
  70. <el-input ref="pastureName" v-model="create.temp.pastureName" placeholder="牧场" style="width: 100%;" :disabled="create.dialogStatus =='see'" /><!-- :disabled="create.dialogStatus =='see'" -->
  71. </el-form-item>
  72. </el-col>
  73. </el-row>
  74. <el-row>
  75. <el-col :span="24">
  76. <el-form-item label="牧场全称:" prop="companyName">
  77. <el-input ref="companyName" v-model="create.temp.companyName" placeholder="牧场全称" style="width: 100%;" :disabled="create.dialogStatus =='see'" />
  78. </el-form-item>
  79. </el-col>
  80. </el-row>
  81. <el-row>
  82. <el-col :span="24">
  83. <el-form-item label="牧场编号:" prop="pastureNumber">
  84. <el-input ref="pastureNumber" v-model="create.temp.pastureNumber" placeholder="牧场编号" style="width: 100%;" :disabled="create.dialogStatus =='see'" />
  85. </el-form-item>
  86. </el-col>
  87. </el-row>
  88. <el-row>
  89. <el-col :span="24">
  90. <el-form-item label="中心: " prop="center">
  91. <el-input ref="center" v-model="create.temp.center" placeholder="中心" style="width: 100%;" :disabled="create.dialogStatus =='see'" />
  92. </el-form-item>
  93. </el-col>
  94. </el-row>
  95. <el-row>
  96. <el-col :span="24">
  97. <el-form-item label="地图经度:" prop="longitude">
  98. <el-input ref="longitude" v-model="create.temp.longitude" type="number" placeholder="请输入数字" :disabled="create.dialogStatus =='see'" style="width: 100%;" />
  99. </el-form-item>
  100. </el-col>
  101. </el-row>
  102. <el-row>
  103. <el-col :span="24">
  104. <el-form-item label="地图纬度:" prop="latitude">
  105. <el-input ref="latitude" v-model="create.temp.latitude" type="number" placeholder="请输入数字" :disabled="create.dialogStatus =='see'" style="width: 100%;" />
  106. </el-form-item>
  107. </el-col>
  108. </el-row>
  109. <el-row>
  110. <el-col :span="24">
  111. <el-form-item label="备注:" prop="note">
  112. <el-input ref="note" v-model="create.temp.note" placeholder="备注" :disabled="create.dialogStatus =='see'" style="width: 100%;" />
  113. </el-form-item>
  114. </el-col>
  115. </el-row>
  116. <el-row v-if="create.dialogStatus !=='create'">
  117. <el-col :span="24">
  118. <el-form-item label="顺序:" prop="sort">
  119. <el-input ref="sort" v-model="create.temp.sort" type="number" placeholder="顺序" :disabled="create.dialogStatus =='see'" style="width: 100%;" />
  120. </el-form-item>
  121. </el-col>
  122. </el-row>
  123. </el-form>
  124. <div slot="footer" class="dialog-footer">
  125. <el-button v-if="create.dialogStatus !== 'see'" :disabled="isokDisable" type="primary" @click="create.dialogStatus =='create'?add_dialog_save():edit_dialog_save()">保存并关闭</el-button>
  126. <el-button @click="create.dialogFormVisible = false;getList()">关闭</el-button>
  127. </div>
  128. </el-dialog>
  129. </div>
  130. </div>
  131. </template>
  132. <script>
  133. import { GetDataByName, GetDataByNames, ExecDataByConfig } from '@/api/common'
  134. import Pagination from '@/components/Pagination'
  135. import { MessageBox } from 'element-ui'
  136. import Cookies from 'js-cookie'
  137. export default {
  138. name: 'RanchManagement',
  139. components: { Pagination },
  140. data() {
  141. return {
  142. requestParams: [
  143. { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }},
  144. { name: 'getareaList', offset: 0, pagecount: 0, returntype: 'Map', parammaps: {}}
  145. ],
  146. findAllPasture: [],
  147. regionList: [], // 所属区域
  148. areaIds:[],
  149. table: {
  150. tableKey: 0,
  151. list: null,
  152. total: 0,
  153. listLoading: true,
  154. getdataListParm: {
  155. name: 'getPastureInforList',
  156. page: 1,
  157. offset: 1,
  158. pagecount: 10,
  159. returntype: 'Map',
  160. parammaps: {}
  161. }
  162. },
  163. create: {
  164. dialogFormVisible: false,
  165. dialogStatus: '',
  166. rules: {
  167. areaId: [{ required: true, message: '必填', trigger: 'blur' }],
  168. pastureName: [{ required: true, message: '必填', trigger: 'blur' }],
  169. companyName: [{ required: true, message: '必填', trigger: 'blur' }],
  170. pastureNumber: [{ required: true, message: '必填', trigger: 'blur' }]
  171. },
  172. temp: {
  173. areaId: '', pastureName: '', pastureNumber: '', longitude: '', latitude: '', note: '', sort: '',center:''
  174. }
  175. },
  176. postDataParam: {},
  177. textMap: { create: '新增', update: '编辑', see: '查看' },
  178. isokDisable: false,
  179. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  180. cellStyle: { padding: 0 + 'px' }
  181. }
  182. },
  183. created() {
  184. this.get_select_list()
  185. this.getList()
  186. },
  187. methods: {
  188. get_select_list() {
  189. GetDataByNames(this.requestParams).then(response => {
  190. this.findAllPasture = response.data.findAllPasture.list
  191. this.regionList = response.data.getareaList.list
  192. this.regionList.forEach(row => {
  193. this.areaIds[row.id]= row.name
  194. });
  195. })
  196. },
  197. getList() {
  198. this.table.listLoading = true
  199. GetDataByName(this.table.getdataListParm).then(response => {
  200. this.table.list = response.data.list
  201. this.table.pageNum = response.data.pageNum
  202. this.table.pageSize = response.data.pageSize
  203. if (response.data.total) {
  204. this.table.total = response.data.total
  205. }
  206. setTimeout(() => {
  207. this.table.listLoading = false
  208. }, 100)
  209. })
  210. },
  211. form_search() {
  212. this.table.getdataListParm.offset = 1
  213. this.getList()
  214. },
  215. resetCreateTemp() {
  216. this.create.temp.areaId = ''
  217. this.create.temp.pastureName = ''
  218. this.create.temp.pastureNumber = ''
  219. this.create.temp.longitude = ''
  220. this.create.temp.latitude = ''
  221. this.create.temp.note = ''
  222. this.create.temp.sort = ''
  223. this.create.temp.center = ''
  224. },
  225. form_add() {
  226. this.resetCreateTemp()
  227. this.create.dialogStatus = 'create'
  228. this.create.dialogFormVisible = true
  229. this.$nextTick(() => {
  230. this.$refs['createTemp'].clearValidate()
  231. })
  232. },
  233. add_dialog_save() {
  234. this.$refs['createTemp'].validate(valid => {
  235. if (valid) {
  236. this.isokDisable = true
  237. setTimeout(() => {
  238. this.isokDisable = false
  239. }, 1000)
  240. this.postDataParam.common = { 'returnmap': '0' }
  241. this.postDataParam.data = []
  242. this.postDataParam.data[0] = { 'name': 'insertPasture', 'type': 'e', 'parammaps': {
  243. pastureName: this.create.temp.pastureName,
  244. pastureNumber: this.create.temp.pastureNumber,
  245. longitude: this.create.temp.longitude,
  246. latitude: this.create.temp.latitude,
  247. note: this.create.temp.note,
  248. center:this.create.temp.center,
  249. companyName: this.create.temp.companyName
  250. }}
  251. this.postDataParam.data[1] = { 'name': 'insertPastureDept', 'type': 'e', 'parammaps': {
  252. pastureName: this.create.temp.pastureName,
  253. pastureId: '@insertPasture.LastInsertId',
  254. areaId: this.create.temp.areaId
  255. }}
  256. ExecDataByConfig(this.postDataParam).then(response => {
  257. console.log('新增保存发送参数', this.postDataParam)
  258. if (response.msg === 'fail') {
  259. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  260. } else {
  261. this.create.dialogFormVisible = false
  262. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  263. this.getList()
  264. }
  265. })
  266. }
  267. })
  268. },
  269. form_edit(row) {
  270. console.log(row)
  271. this.create.temp = Object.assign({}, row)
  272. this.create.dialogStatus = 'update'
  273. this.create.dialogFormVisible = true
  274. },
  275. edit_dialog_save() {
  276. this.$refs['createTemp'].validate(valid => {
  277. if (valid) {
  278. this.isokDisable = true
  279. setTimeout(() => {
  280. this.isokDisable = false
  281. }, 1000)
  282. this.postDataParam.common = { 'returnmap': '0' }
  283. this.postDataParam.data = []
  284. this.postDataParam.data[0] = { 'name': 'updatePastureDept', 'type': 'e', 'parammaps': {
  285. name:this.create.temp.pastureName,
  286. companyName:this.create.temp.companyName,
  287. pastureNumber:this.create.temp.pastureNumber,
  288. center:this.create.temp.center,
  289. region:this.areaIds[this.create.temp.areaid],
  290. longitude: this.create.temp.longitude,
  291. latitude: this.create.temp.latitude,
  292. note: this.create.temp.note,
  293. id: this.create.temp.id,
  294. sort: this.create.temp.sort
  295. }}
  296. this.postDataParam.data[1] = { 'name': 'updateDepartment', 'type': 'e', 'parammaps': {
  297. dname: this.create.temp.pastureName,
  298. pastureId: this.create.temp.areaid,
  299. id: this.create.temp.id
  300. }}
  301. ExecDataByConfig(this.postDataParam).then(response => {
  302. console.log('编辑保存发送参数', this.postDataParam)
  303. if (response.msg === 'fail') {
  304. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  305. } else {
  306. this.create.dialogFormVisible = false
  307. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  308. this.getList()
  309. }
  310. })
  311. }
  312. })
  313. },
  314. form_see(row) {
  315. this.create.dialogStatus = 'see'
  316. this.create.dialogFormVisible = true
  317. this.create.temp = Object.assign({}, row)
  318. }
  319. }
  320. }
  321. </script>
  322. <style>
  323. input::-webkit-outer-spin-button,
  324. input::-webkit-inner-spin-button {
  325. -webkit-appearance: none;
  326. }
  327. input[type="number"]{
  328. -moz-appearance: textfield;
  329. }
  330. </style>