Browse Source

data展示还没有做

East 4 years ago
parent
commit
d6a1ab4e06
2 changed files with 548 additions and 0 deletions
  1. 13 0
      src/mock/modules/sys-menu.js
  2. 535 0
      src/views/modules/sys/api.vue

+ 13 - 0
src/mock/modules/sys-menu.js

@@ -494,6 +494,19 @@ var navDataList = [
         'orderNum': 7,
         'open': null,
         'list': null
+      },
+      {
+        'menuId': 55,
+        'parentId': 1,
+        'parentName': null,
+        'name': '接口测试',
+        'url': 'sys/api',
+        'perms': null,
+        'type': 1,
+        'icon': 'daohang',
+        'orderNum': 8,
+        'open': null,
+        'list': null
       }
     ]
   },

+ 535 - 0
src/views/modules/sys/api.vue

@@ -0,0 +1,535 @@
+<template>
+  <div class="branch">
+    <el-table
+      height="670"
+      :data="dataList"
+      style="width: 100%">
+      <!-- <el-table-column
+        type="selection"
+        header-align="center"
+        align="center"
+        width="50">
+      </el-table-column> -->
+      <el-table-column
+        prop="name"
+        header-align="center"
+        align="center"
+        label="接口名称">
+      </el-table-column>
+      <el-table-column
+        prop="for"
+        header-align="center"
+        align="center"
+        label="用途">
+      </el-table-column>
+      <el-table-column
+        fixed="right"
+        header-align="center"
+        align="center"
+        label="操作">
+        <template slot-scope="scope">
+          <el-button v-if="isAuth('sys:user:update')" type="success" size="mini" @click="addOrUpdateHandle(scope.row)">测试</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+    <div class="block">
+      <el-pagination
+        @size-change="sizeChangeHandle"
+        @current-change="currentChangeHandle"
+        :current-page="pageIndex"
+        :page-sizes="[10, 12, 15, 20]"
+        :page-size="pageSize"
+        layout="total, sizes, prev, pager, next, jumper"
+        :total="totalPage">
+      </el-pagination>
+    </div>
+    <el-dialog
+      title="测试'"
+      :close-on-click-modal="false"
+      :visible.sync="visible"
+      @close="cancel">
+      <template v-if="row.type === 0">
+        <el-form :model="form0" :rules="dataRule" ref="form" @keyup.enter.native="formSubmit()" label-width="80px">
+          <el-form-item label="耳标号" prop="pigEarTagNo">
+            <el-input v-model="form0.pigEarTagNo" placeholder="年猪耳标号"></el-input>
+          </el-form-item>
+        </el-form>
+      </template>
+      <template v-else>
+        <el-form :model="form1" :rules="dataRule" ref="form" @keyup.enter.native="formSubmit()" label-width="80px">
+          <el-form-item label="品种" prop="breedName">
+            <el-input v-model="form1.breedName" placeholder="品种名称"></el-input>
+          </el-form-item>
+        </el-form>
+      </template>
+      
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="cancel">取消</el-button>
+        <el-button type="primary" @click="formSubmit()">确定</el-button>
+      </span>
+    </el-dialog>
+  </div>
+</template>
+<script>
+export default {
+  data () {
+    return {
+      dataForm: {
+        key: ''
+      },
+      dataList: [
+        {
+          name: 'testGetPigInfo',
+          for: '获取年猪信息',
+          // params: ['pigEarTagNo']
+          type: 0
+        },
+        {
+          name: 'testGetImage',
+          for: '获取年猪图片',
+          // params: ['pigEarTagNo']
+          type: 0
+        },
+        {
+          name: 'testGetListByBreed',
+          for: '根据品种获取年猪信息',
+          // params: [
+          //   'breedName',
+          //   'currentPage',
+          //   'pageSize'
+          // ]
+          type: 1
+        },
+        {
+          name: 'testGetIndoorEnv',
+          for: '获取室内环境',
+          // params: ['pigEarTagNo']
+          type: 0
+        },
+        {
+          name: 'testAdopt',
+          for: '获取认养情况',
+          // params: ['pigEarTagNo']
+          type: 0
+        },
+        {
+          name: 'testOutFence',
+          for: '获取出栏情况',
+          // params: ['pigEarTagNo']
+          type: 0
+        }
+      ],
+      pageIndex: 1,
+      pageSize: 10,
+      totalPage: 0,
+      visible: false,
+      form0: {
+        pigEarTagNo: ''
+      },
+      form1: {
+        breedName: '',
+        currentPage: '',
+        pageSize: ''
+      },
+      row: [],
+      api: '',
+      dataRule: { // 校验规则
+        name: [
+          { required: true, message: '牧场名称不能为空', trigger: 'blur' },
+          { min: 1, max: 50, message: '长度在 1 到 50 个字符之间', trigger: ['blur', 'change'] },
+          { type: 'string' , message: '只允许输入中英文、数字、-与_', pattern: /[\w\u4E00-\u9FA5\-]+$/g }
+        ],
+        manager: [
+          { required: true, message: '管理员不能为空', trigger: 'blur' },
+          { min: 1, max: 5, message: '长度在 1 到 5 个字符之间', trigger: ['blur', 'change'] },
+          { type: 'string' , message: '只允许输入中英文、数字、-与_', pattern: /[\w\u4E00-\u9FA5\-]+$/g }
+        ],
+        selectedOptions: [
+          { required: true, message: '省市区不能为空', trigger: 'blur' }
+        ],
+        location2: [
+          { required: true, message: '具体地址不能为空', trigger: 'blur' },
+          { type : 'string' , message: '只允许输入中英文、数字、_、!与!的输入', pattern: /[\w\u4E00-\u9FA5\!\!]+$/g }
+        ],
+        buildTime: [
+          { required: true, message: '日期不能为空', trigger: 'blur' }
+        ]
+      }
+    }
+  },
+  created () {
+    // this.getDataList()
+  },
+  methods: {
+    // comLocation(location) {
+    //   let arr = location.split(",")
+    //   let loc = ''
+    //   if (arr.length === 1) {
+    //     return location
+    //   }
+    //   for (let i = 0; i < arr.length - 1; i++) {
+    //     loc += CodeToText[arr[i]]
+    //   }
+    //   loc += arr[arr.length - 1]
+    //   return loc
+    // },
+    // 获取数据列表
+    // getDataList () {
+    //   this.dataListLoading = true
+    //   this.$http({
+    //     url: this.$http.adornUrl('/management/pasture/list'),
+    //     method: 'post',
+    //     params: this.$http.adornParams({
+    //       page: this.pageIndex,
+    //       limit: this.pageSize,
+    //       keywords: this.dataForm.key
+    //     })
+    //   }).then(({ data }) => {
+    //     if (data && data.code === 0) {
+    //       this.dataList = data.page.list
+    //       this.totalPage = data.page.totalCount
+    //     } else {
+    //       this.dataList = []
+    //       this.totalPage = 0
+    //     }
+    //     this.dataListLoading = false
+    //   })
+    // },
+    // 每页数
+    sizeChangeHandle (val) {
+      this.pageSize = val
+      this.pageIndex = 1
+      this.getDataList()
+    },
+    // 获取地址
+    // getlocation () {
+    //   var loc = "";
+    //   this.form.location1 = ''
+    //   for (let i = 0; i < this.form.selectedOptions.length; i++) {
+    //     loc += CodeToText[this.form.selectedOptions[i]]
+    //     this.form.location1 += this.form.selectedOptions[i] + ','
+    //   }
+    //   this.loc = loc
+    //   console.log(loc);
+    // },
+    // 当前页
+    currentChangeHandle (val) {
+      this.pageIndex = val
+      this.getDataList()
+    },
+    // 新增 or 修改牧场
+    addOrUpdateHandle (row) {
+      // 显示牧场新增 or 修改面板
+      this.visible = true
+      // console.log(row);
+      this.form0 = {}
+      this.form1 = {}
+      this.row = row
+      // this.api = row.name
+      // row.params.forEach(param => {
+      //   this.row.push(param)
+      //   this.form[param] = ''
+      // })
+    },
+    formSubmit() {
+      let form = {}
+      this.row.type === 0? form = this.form0: form = this.form1
+      this.$http({
+        url: this.$http.adornUrl('/management/localTest/' + this.row.name),
+        method: 'get',
+        params: this.$http.adornParams(form)
+      }).then(result => {
+        console.log(result);
+      })
+      // this.resetForm()
+      // this.visible = false
+    },
+    // 选择n个牧场
+    // selectionChangeHandle (val) {
+    //   this.selectionDataList = []
+    //   val.forEach(item => {
+    //     this.selectionDataList.push(item.id)
+    //   });
+    // },
+    // 删除n个牧场
+    // deleteHandle (id) {
+    //   this.$confirm(`确定删除牧场?`, '提示', {
+    //     confirmButtonText: '确定',
+    //     cancelButtonText: '取消',
+    //     type: 'warning'
+    //   }).then(() => {
+    //     // 删除操作
+    //     if (id) {
+    //       this.selectionDataList.push(id)
+    //     }
+    //     if (this.selectionDataList.length <= 0) {
+    //       return
+    //     }
+    //     this.$http({
+    //       url: this.$http.adornUrl('/management/pasture/delete'),
+    //       method: 'post',
+    //       data: this.$http.adornData(this.selectionDataList, false)
+    //     }).then(result => {
+    //       if (result.data.code === 0) {
+    //         this.$message({
+    //           message: '成功删除牧场',
+    //           type: 'success',
+    //           duration: 1000
+    //         })
+    //         // pageIndex修正
+    //         this.totalPage -= this.selectionDataList.length
+    //         let pages = Math.ceil(this.totalPage / this.pageSize)
+    //         this.pageIndex = this.pageIndex > pages? pages: this.pageIndex
+    //         this.pageIndex = this.pageIndex < 1? pages: this.pageIndex
+    //       } else {
+    //         this.$confirm(result.data.msg, '删除失败', {
+    //           confirmButtonText: '确定',
+    //           cancelButtonText: '取消',
+    //           type: 'warning'
+    //         }).then(() => {
+    //           console.log('牧场删除失败');
+    //         }).catch(() => {})
+    //       }
+    //       this.resetForm()
+    //       this.selectionDataList = []
+    //     })
+    //   }).catch(() => {})
+    // },
+    // formSubmit () {
+    //   if (this.form.id) {
+    //     /** 修改 */
+    //     // 输入是否完整
+    //     if (!this.confirmComplete()) {
+    //       return
+    //     }
+    //     // 输入长度是否合法
+    //     if (!this.confirmLength()) {
+    //       return
+    //     }
+    //     // 输入是否合法
+    //     if (!this.confirmInput()) {
+    //       return
+    //     }
+    //     // 进行修改操作
+    //     this.$http({
+    //       url: this.$http.adornUrl('/management/pasture/update'),
+    //       method: 'post',
+    //       data: this.$http.adornData({
+    //         id: this.form.id,
+    //         location: this.form.location,
+    //         manager: this.form.manager,
+    //         name: this.form.name,
+    //         buildTime: this.form.buildTime,
+    //         frontLocation: this.form.loc
+    //       })
+    //     }).then(result => {
+    //       if (result.data.code === 0) {
+    //         this.resetForm();
+    //         this.visible = false;
+    //         this.$message({
+    //           message: '成功修改牧场信息',
+    //           type: 'success',
+    //           duration: 1000
+    //         })
+    //       } else {
+    //         if (result.data.code === 600) {
+    //           let msg = result.data.msg.split('-')
+    //           this.$message({
+    //             message: `牧场名称 <p style="color:#333; display:inline">${msg[0]}</p> 已经存在!`,
+    //             type: "error",
+    //             duration: 1000,
+    //             dangerouslyUseHTMLString: true
+    //           })
+    //           return
+    //         }
+    //         this.$message.error(result.data.msg);
+    //       }
+    //     })
+    //   } else {
+    //     /** 新增 */
+    //     // 输入是否完整
+    //     if (!this.confirmComplete(1)) {
+    //       return
+    //     }
+    //     // 输入长度是否合法
+    //     if (!this.confirmLength()) {
+    //       return
+    //     }
+    //     // 输入是否合法
+    //     if (!this.confirmInput()) {
+    //       return
+    //     }
+    //     // 进行新增操作
+    //     this.$http({
+    //       url: this.$http.adornUrl('/management/pasture/save'),
+    //       method: 'post',
+    //       data: this.$http.adornData({
+    //         location: this.form.location,
+    //         manager: this.form.manager,
+    //         name: this.form.name,
+    //         buildTime: this.form.buildTime,
+    //         frontLocation: this.form.loc
+    //       })
+    //     }).then(result => {
+    //       if (result.data.code === 0) {
+    //         // 新增pageIndex的修正
+    //         this.totalPage++
+    //         let pages = Math.ceil(this.totalPage / this.pageSize)
+    //         this.pageIndex = this.pageIndex < pages? pages: this.pageIndex
+    //         this.resetForm();
+    //         this.visible = false;
+    //         this.$message({
+    //           message: '成功添加牧场',
+    //           type: 'success',
+    //           duration: 1000
+    //         })
+    //       } else {
+    //         if (result.data.code === 600) {
+    //           let msg = result.data.msg.split('-')
+    //           this.$message({
+    //             message: `牧场名称 <p style="color:#333; display:inline">${msg[0]}</p> 已经存在!`,
+    //             type: "error",
+    //             duration: 1000,
+    //             dangerouslyUseHTMLString: true
+    //           })
+    //           return
+    //         }
+    //         this.$message.error(result.data.msg)
+    //       }
+    //     })
+    //   }
+    // },
+    // 清空form
+    resetForm () {
+      // for (let i in this.form) {
+      //   this.form[i] = ''
+      // }
+      // this.form.selectedOptions = []
+      // this.getDataList()
+      this.form = {}
+      this.row = []
+      this.api = ''
+    },
+    // 取消
+    cancel () {
+      this.visible = false
+      // 如果新增,则不保留form
+      this.resetForm()
+      // if (this.form.id) {
+      //   this.resetForm()
+      // }
+    },
+    // 校验输入是否完整
+    // validComplete (val) {
+    //   var loc = "";
+    //   this.form.location1 = ''
+    //   for (let i = 0; i < this.form.selectedOptions.length; i++) {
+    //     loc += CodeToText[this.form.selectedOptions[i]]
+    //     this.form.location1 += this.form.selectedOptions[i] + ','
+    //   }
+    //   this.loc = loc
+    //   this.form.location = this.form.location1 + this.form.location2
+    //   this.form.loc = this.loc + this.form.location2
+    //   val && (delete this.form.id)
+    //   for (let i in this.form) {
+    //     if (!this.form[i].toString()) {
+    //       return false
+    //     }
+    //   }
+    //   return true
+    // },
+    // 如不完整,则提示
+    // confirmComplete (val) {
+    //   if (this.validComplete(val)) {
+    //     return true
+    //   }
+    //   this.$confirm(`所有项均为必填项`, '提示', {
+    //     confirmButtonText: '确定',
+    //     cancelButtonText: '取消',
+    //     type: 'warning'
+    //   }).then(() => {
+    //     console.log('牧场输入不完整');
+    //   }).catch(() => {})
+    //   return false
+    // },
+    // // 校验输入是否合法
+    // validInput () {
+    //   // 只允许中文、英文、数字、-、_的输入,取反
+    //   const reg = /[^\w\u4E00-\u9FA5\_\-]/g
+    //   if (reg.test(this.form.name)) {
+    //     return 0
+    //   }
+    //   if (reg.test(this.form.manager)) {
+    //     return 1
+    //   }
+    //   // 只允许中文、英文、下划线、!、!的输入
+    //   const a = /[^\w\u4E00-\u9FA5\!\!]/g
+    //   if (a.test(this.form.location2)) {
+    //     return 2
+    //   }
+    //   // 不允许纯数字、字母的出现
+    //   const b = /^[\w]*([a-zA-Z][0-9]|[0-9][a-zA-Z])[\w]*$/
+    //   // 不允许纯符号的出现
+    //   const c = /^[\_\-\!\!]*[\_\-\!\!]*$/
+    //   if (b.test(this.form.name) || b.test(this.form.manager) || b.test(this.form.location2) || c.test(this.form.name) || c.test(this.form.manager) || c.test(this.form.location2)) {
+    //     return 3
+    //   }
+    //   // 建立日期不得大于今日
+    //   let build = new Date(this.form.buildTime)
+    //   let now = new Date()
+    //   if (build > now) {
+    //     console.log('建立日期有误');
+    //     return 4
+    //   }
+    //   return 5
+    // },
+    // // 如不合法,则提示
+    // confirmInput () {
+    //   if (this.validInput() === 5) {
+    //     return true
+    //   }
+    //   let msg = [
+    //     '牧场名称只允许中英文、数字、-、_的输入',
+    //     '管理员只允许中英文、数字、-、_的输入',
+    //     '具体地址只允许中英文、数字、_、!与!的输入',
+    //     '不允许输入纯数字、纯字母或纯符号',
+    //     '建立日期选择有误'
+    //   ]
+    //   this.$confirm(msg[this.validInput()], '提示', {
+    //     confirmButtonText: '确定',
+    //     cancelButtonText: '取消',
+    //     type: 'warning'
+    //   }).then(() => {
+    //     console.log('输入不合法');
+    //   }).catch(() => {})
+    //   return false
+    // },
+    // // 长度校验
+    // validLength () {
+    //   if (this.form.name.length > 50) {
+    //     return false
+    //   }
+    //   if (this.form.manager.length > 5) {
+    //     return false
+    //   }
+    //   return true
+    // },
+    // // 如长度不合法,则提示
+    // confirmLength () {
+    //   if (this.validLength()) {
+    //     return true
+    //   }
+    //   this.$confirm(`牧场名称长度限制50,管理员姓名长度限制5`, '提示', {
+    //     confirmButtonText: '确定',
+    //     cancelButtonText: '取消',
+    //     type: 'warning'
+    //   }).then(() => {
+    //     console.log('输入不合法');
+    //   }).catch(() => {})
+    //   return false
+    // }
+  }
+}
+</script>
+<style scoped>
+</style>