projectList.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. <template>
  2. <div id="project">
  3. <el-container>
  4. <el-main>
  5. <div style="margin-bottom: 10px">
  6. <el-button size="medium" icon="el-icon-back" type="text" @click="back">返回</el-button>
  7. <span style="margin-left: 20px; font-size: 18px">网关列表</span>
  8. </div>
  9. <div style="margin-bottom: 12px">
  10. <span style="margin-left: 3px; font-size: 16px; color: #545c64">项目编号:{{projectData.number}}</span>
  11. <span style="margin-left: 20px; font-size: 16px;color: #545c64">项目名称:{{projectData.name}}</span>
  12. </div>
  13. <el-button size="medium" icon="el-icon-search" style="margin-bottom: 15px" @click="search(searchFormData)">
  14. 查询
  15. </el-button>
  16. <el-button size="medium" icon="el-icon-plus" @click="showAdd" style="margin-left: 0">新增</el-button>
  17. <div style="padding: 10px;background-color: white">
  18. <el-form :inline="true" :model="searchFormData" style="background-color: white;">
  19. <el-form-item label="编号">
  20. <el-input placeholder="编号" size="mini" v-model="searchFormData.number"></el-input>
  21. </el-form-item>
  22. <el-form-item label="网关ip">
  23. <el-input placeholder="网关ip" size="mini" v-model="searchFormData.ip"></el-input>
  24. </el-form-item>
  25. <el-form-item label="定位">
  26. <el-input placeholder="定位" size="mini" v-model="searchFormData.location"></el-input>
  27. </el-form-item>
  28. <!-- <el-form-item label="运营商编号" style="margin-top: 6px" size="mini">-->
  29. <!-- <el-select v-model="searchFormData.operatorNumber" placeholder="运营商编号" style="width: 180px" clearable>-->
  30. <!-- <el-option :value="i.number" v-for="(i,index) in operators" :key="index" :label="i.number"></el-option>-->
  31. <!-- </el-select>-->
  32. <!-- </el-form-item>-->
  33. <el-dialog title="网关" :visible.sync="dialogFormVisible" style="width: 70% ; margin-left: 300px ;">
  34. <el-form label-position="left" :model="formData">
  35. <el-row style="margin-left: 15px">
  36. <el-form-item label="编号" style="margin-right: 50px;margin-left: 22px">
  37. <el-input v-model="formData.number"></el-input>
  38. </el-form-item>
  39. <el-form-item label="网关ip">
  40. <el-input v-model="formData.ip"></el-input>
  41. </el-form-item>
  42. </el-row>
  43. <el-row style="margin-left: 15px">
  44. <el-form-item label="定位" style="margin-right: 20px;margin-left: 22px">
  45. <el-input v-model="formData.location"></el-input>
  46. </el-form-item>
  47. <el-form-item label="运营商编号">
  48. <el-select v-model="formData.operatorNumber" placeholder="运营商编号" style="width: 202px">
  49. <el-option :value="i.number" v-for="(i,index) in operators" :key="index"
  50. :label="i.number"></el-option>
  51. </el-select>
  52. </el-form-item>
  53. </el-row>
  54. <el-form-item label="项目编号">
  55. <el-select v-model="formData.projectNumber" placeholder="项目编号" style="width: 202px">
  56. <el-option :value="i.number" v-for="(i,index) in projects" :key="index"
  57. :label="i.number"></el-option>
  58. </el-select>
  59. </el-form-item>
  60. </el-form>
  61. <div slot="footer" class="dialog-footer" style="text-align: center">
  62. <el-button @click="cancel()">取 消</el-button>
  63. <el-button type="primary" @click="addOrEditMehtond()">确 定</el-button>
  64. </div>
  65. </el-dialog>
  66. </el-form>
  67. <el-table :data="tableData">
  68. <el-table-column type="selection"></el-table-column>
  69. <el-table-column prop="number" label="编号"></el-table-column>
  70. <el-table-column prop="ip" label="网关ip"></el-table-column>
  71. <el-table-column prop="location" label="定位"></el-table-column>
  72. <el-table-column label="网关状态">
  73. <template slot-scope="scope">
  74. {{ String(scope.row.useStatus) === '0' ? '已禁用' : '正常' }}
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="操作">
  78. <template slot-scope="scope">
  79. <el-button type="text" size="medium" @click="showEdit(scope.row)">编辑</el-button>
  80. <el-button type="text" size="medium" @click="gatewayList(scope.row)">设备</el-button>
  81. <el-button type="text" size="medium" @click="del(scope.row)" style="color: #c01920">删除</el-button>
  82. <el-button
  83. style="color: #c01920"
  84. type="text"
  85. size="medium"
  86. class="delBut non"
  87. @click="statusHandle(scope.row)"
  88. >
  89. {{ scope.row.useStatus == '1' ? '禁用' : '启用' }}
  90. </el-button>
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. <el-pagination
  95. style="margin-top: 15px;text-align: center"
  96. background
  97. layout="prev, pager, next"
  98. :page-size="pager.pageSize"
  99. :current-page="pager.pageIndex"
  100. :total="pager.itemCount"
  101. @current-change="handleCurrentChange"
  102. >
  103. </el-pagination>
  104. </div>
  105. </el-main>
  106. </el-container>
  107. </div>
  108. </template>
  109. <script>
  110. export default {
  111. name: 'project',
  112. data() {
  113. return {
  114. operators: [],
  115. projects: [],
  116. api: {
  117. list: this.$api.gateway.list,
  118. delete: this.$api.gateway.delete,
  119. add: this.$api.gateway.add,
  120. update: this.$api.gateway.update,
  121. },
  122. projectData:{
  123. name:'',
  124. number:'',
  125. code:'',
  126. },
  127. value: true,
  128. addOrEdit: 1,
  129. dialogFormVisible: false,
  130. pager: {
  131. pageSize: 2,
  132. pageIndex: 1,
  133. itemCount: 0,
  134. },
  135. tableData:
  136. [{
  137. number: '',
  138. ip: '',
  139. location: '',
  140. useStatus: '1'
  141. }],
  142. formData: {
  143. number: '',
  144. ip: '',
  145. location: '',
  146. useStatus: '1',
  147. operatorNumber: '',
  148. projectNumber: ''
  149. },
  150. searchFormData:
  151. {
  152. number: '',
  153. ip: '',
  154. location: '',
  155. useStatus: '1',
  156. operatorNumber: '',
  157. projectNumber: ''
  158. }
  159. }
  160. },
  161. created: function () {
  162. this.getOperatorNumber();
  163. this.getProjectNumber();
  164. this.loadData();
  165. },
  166. methods: {
  167. //切换页码
  168. handleCurrentChange(index) {
  169. this.loadData(index)
  170. },
  171. loadData(index) {
  172. var row = this.$route.query.row;
  173. console.log(row)
  174. this.projectData = row
  175. console.log(this.projectData.name)
  176. const vm = this;
  177. vm.$http.get(vm.api.list, {
  178. params: {
  179. pageSize: 5,
  180. pageIndex: index ? index : 1,
  181. number: this.searchFormData.number,
  182. ip: this.searchFormData.ip,
  183. location: this.searchFormData.location,
  184. projectNumber: this.projectData.number,
  185. }
  186. })
  187. .then((response) => {
  188. // vm.paper = response.data.data.paper;
  189. console.log(response.data.data);
  190. vm.pager = response.data.data.pager
  191. vm.tableData = response.data.data.gateways;
  192. })
  193. },
  194. getOperatorNumber() {
  195. const vm = this;
  196. vm.$http.get(vm.$api.operator.list, {
  197. params: {
  198. number: this.searchFormData.operatorNumber,
  199. }
  200. }).then((resp) => {
  201. console.log(resp.data.data.operators)
  202. vm.operators = resp.data.data.operators
  203. })
  204. },
  205. getProjectNumber() {
  206. const vm = this;
  207. vm.$http.get(vm.$api.project.list, {
  208. params: {
  209. number: this.searchFormData.projectNumber,
  210. }
  211. }).then((resp) => {
  212. console.log(resp.data.data.projects)
  213. vm.projects = resp.data.data.projects
  214. })
  215. },
  216. search() {
  217. //console.log(this.searchFormData)
  218. this.loadData();
  219. },
  220. showAdd() {
  221. this.dialogFormVisible = true;
  222. this.formData.number = '',
  223. this.formData.ip = '',
  224. this.formData.location = '',
  225. this.formData.operatorNumber = '',
  226. this.formData.projectNumber = ''
  227. },
  228. showEdit(row) {
  229. this.dialogFormVisible = true;
  230. this.editRow = JSON.parse(JSON.stringify(row));
  231. this.formData = this.editRow
  232. this.addOrEdit = 2
  233. }
  234. ,
  235. addOrEditMehtond() {
  236. const vm = this;
  237. if (this.addOrEdit == 2) {
  238. vm.$http.get(vm.api.update, {
  239. params: {
  240. number: this.formData.number,
  241. ip: this.formData.ip,
  242. location: this.formData.location,
  243. useStatus: this.formData.useStatus,
  244. operatorNumber: this.formData.operatorNumber,
  245. projectNumber: this.formData.projectNumber,
  246. operatorCode: this.formData.operatorCode,
  247. projectCode: this.formData.projectCode,
  248. }
  249. })
  250. .then((response) => {
  251. console.log(response)
  252. if (response.data.status == 200) {
  253. this.$message({
  254. type: 'success',
  255. showClose: true,
  256. message: response.data.desc
  257. })
  258. }
  259. this.dialogFormVisible = false;
  260. this.loadData();
  261. })
  262. .catch(() => {
  263. });
  264. }
  265. if (this.addOrEdit == 1) {
  266. vm.$http.get(vm.api.add, {
  267. params: {
  268. number: this.formData.number,
  269. ip: this.formData.ip,
  270. location: this.formData.location,
  271. useStatus: this.formData.useStatus,
  272. operatorNumber: this.formData.operatorNumber,
  273. projectNumber: this.formData.projectNumber,
  274. operatorCode: this.formData.operatorCode,
  275. projectCode: this.formData.projectCode,
  276. }
  277. })
  278. .then((response) => {
  279. if (response.data.status == 200) {
  280. this.dialogFormVisible = false;
  281. this.$message({
  282. type: 'success',
  283. showClose: true,
  284. message: response.data.desc
  285. })
  286. this.loadData();
  287. }
  288. })
  289. }
  290. },
  291. del(row) {
  292. const vm = this;
  293. this.$confirm('确认删除', '提示', {
  294. type: 'warning'
  295. }).then(() => {
  296. vm.$http.get(vm.api.delete, {
  297. params: {
  298. code: row.code,
  299. }
  300. })
  301. .then((response) => {
  302. console.log(response)
  303. if (response.data.status == 200) {
  304. this.$message({
  305. type: 'success',
  306. showClose: true,
  307. message: response.data.desc
  308. })
  309. }
  310. this.loadData();
  311. })
  312. })
  313. .catch(() => {
  314. this.$message({
  315. type: 'info',
  316. showClose: true,
  317. message: '取消删除'
  318. })
  319. });
  320. },
  321. cancel() {
  322. this.$message({
  323. message: '操作取消',
  324. showClose: true,
  325. type: 'info'
  326. });
  327. this.dialogFormVisible = false;
  328. },
  329. //启用/停用网关
  330. statusHandle(row) {
  331. const vm = this;
  332. this.$confirm('是否进行此操作', '提示', {
  333. type: 'warning'
  334. }).then(() => {
  335. vm.$http.get(vm.api.update, {
  336. params: {
  337. number: row.number,
  338. ip: row.ip,
  339. location: row.location,
  340. operatorNumber: row.operatorNumber,
  341. projectNumber: row.projectNumber,
  342. operatorCode: row.operatorCode,
  343. projectCode: row.projectCode,
  344. code: row.code,
  345. valid: row.valid,
  346. useStatus: row.useStatus == 1 ? 0 : 1,
  347. }
  348. })
  349. .then((response) => {
  350. console.log(row)
  351. // console.log(response)
  352. if (response.data.status == 200) {
  353. this.$message({
  354. type: 'success',
  355. showClose: true,
  356. message: response.data.desc
  357. })
  358. }
  359. this.loadData();
  360. })
  361. })
  362. .catch(() => {
  363. this.$message({
  364. type: 'info',
  365. showClose: true,
  366. message: '操作取消'
  367. })
  368. });
  369. },
  370. gatewayList(row) {
  371. let vm = this;
  372. vm.$router.push({
  373. path: '/gatewayList',
  374. query: {row: row}
  375. })
  376. },
  377. back() {
  378. let vm = this;
  379. vm.$router.back()
  380. }
  381. }
  382. }
  383. </script>
  384. <style scoped>
  385. .el-form-item {
  386. margin-right: 10px;
  387. margin-left: 10px;
  388. margin-bottom: 10px;
  389. margin-top: 0px;
  390. }
  391. </style>