瀏覽代碼

接口测试完成

East 4 年之前
父節點
當前提交
1fd01d1bcd
共有 1 個文件被更改,包括 10 次插入371 次删除
  1. 10 371
      src/views/modules/sys/api.vue

+ 10 - 371
src/views/modules/sys/api.vue

@@ -4,12 +4,6 @@
       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"
@@ -49,14 +43,14 @@
       :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 :model="form0" 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 :model="form1" 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>
@@ -81,41 +75,31 @@ export default {
         {
           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
         }
       ],
@@ -133,85 +117,15 @@ export default {
       },
       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
@@ -219,17 +133,10 @@ export default {
     },
     // 新增 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 = {}
@@ -239,173 +146,18 @@ export default {
         method: 'get',
         params: this.$http.adornParams(form)
       }).then(result => {
-        console.log(result);
+        this.$confirm(result.data.msg, '返回信息', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          console.log('接口测试');
+          this.visible = false
+        }).catch(() => {})
       })
-      // 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 = ''
@@ -413,121 +165,8 @@ export default {
     // 取消
     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>