index.vue 16 KB

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