Ver Fonte

Merge branch 'feature/ci-test3' of duanxiaoduan/tmr-group-admin into develop

duanxiaoduan há 1 ano atrás
pai
commit
f7a2358517

+ 5 - 1
src/store/modules/permission.js

@@ -102,7 +102,11 @@ const actions = {
         if(response.code == 200){
           sessionStorage.setItem('buttonList', JSON.stringify(response.data.menu_buttons_path))   //所有按钮
           sessionStorage.setItem('pastureList', JSON.stringify(response.data.pasture_list))       //所属牧场
-          Cookies.set('pastureId', response.data.pasture_list[0].id)
+          if(response.data.pasture_list.length>0){
+            Cookies.set('pastureId', response.data.pasture_list[0].id)
+          }else{
+            Cookies.set('pastureId', 0)
+          }
           const menus = response.data.menu_list
           if (menus.length === 0) {
             reject('menus data is null')

+ 19 - 21
src/utils/request.js

@@ -90,28 +90,26 @@ service.interceptors.response.use(
       return Promise.reject(error)
     }
     // 设置请求超时次数
-    config.__retryCount = config.__retryCount || 0
-    if (config.__retryCount >= 3) {
-      // Message({ message:error.message, type: 'error', duration: 5 * 1000 })
-      Message({ message:'操作失败'+error.response.data.errors[0], type: 'error', duration: 5 * 1000 })
-      // Message.error((error && error.data && error.data.msg) || '请求超时')
-      return Promise.reject(error)
-    }
-    config.__retryCount += 1
-    let backoff = new Promise((resolve) => {
-      setTimeout(() => {
-        resolve()
-      }, config.retryDelay || 1)
-    })
-    return backoff.then(() => {
-      return service(config)
-    })
-    // Message({
-    //   message: "操作错误!"+error.response.data.errors[0],
-    //   type: 'error',
-    //   duration: 5 * 1000
+    // config.__retryCount = config.__retryCount || 0
+    // if (config.__retryCount >= 3) {
+    //   Message({ message:'操作失败'+error.response.data.errors[0], type: 'error', duration: 5 * 1000 })
+    //   return Promise.reject(error)
+    // }
+    // config.__retryCount += 1
+    // let backoff = new Promise((resolve) => {
+    //   setTimeout(() => {
+    //     resolve()
+    //   }, config.retryDelay || 1)
+    // })
+    // return backoff.then(() => {
+    //   return service(config)
     // })
-    // return Promise.reject(error)
+    Message({
+      message: "操作错误!"+error.response.data.errors[0],
+      type: 'error',
+      duration: 5 * 1000
+    })
+    return Promise.reject(error)
   }
 )
 

+ 45 - 28
src/views/rangeManagement/feedTable/index.vue

@@ -40,11 +40,11 @@
       <!-- <el-button class="success" icon="el-icon-plus" @click="handleGetSapCode">获取SAP编码</el-button> -->
       <el-button v-if="isDelete" class="danger" icon="el-icon-delete" @click="handleDelete">删除</el-button>
       <!-- <el-button class="success" icon="el-icon-receiving" @click="handleFeedBank">饲料库</el-button> -->
-     <!-- <el-button v-if="isOrder" icon="el-icon-sort" class="success" @click="handleChangeOrder">更改顺序</el-button>
+     <el-button v-if="isOrder && isSort" icon="el-icon-sort" class="success" @click="handleChangeOrder">更改顺序</el-button>
        <div v-else style="display: inline-block;">
-        <el-button icon="el-icon-folder-checked" class="success" @click="saveChangeOrder">保存</el-button>
-        <el-button icon="el-icon-close" class="sortCancel" @click="cancelChangeOrder">取消</el-button>
-      </div> -->
+        <el-button v-if="isSort" icon="el-icon-folder-checked" class="success" @click="saveChangeOrder">保存</el-button>
+        <el-button v-if="isSort" icon="el-icon-close" class="sortCancel" @click="cancelChangeOrder">取消</el-button>
+      </div>
       <el-upload style="float: right;" action="#" :http-request="httpRequest" :show-file-list="false" :on-change="handleChange" :before-upload="beforeAvatarUpload" multiple accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
         <el-button v-if="isImport" class="import" icon="el-icon-download" style="float: right;">导入</el-button>
       </el-upload>
@@ -102,7 +102,7 @@
             <span v-if="scope.row.confirm_start == 1">启用</span>
             <span v-else>禁用</span>
           </template>
-        </u-table-column> 
+        </u-table-column>
         <u-table-column label="继电器位置" min-width="80px" align="center" prop="relay_locations" />
         <u-table-column label="无上域" min-width="60px" align="center">
           <template slot-scope="scope">
@@ -921,7 +921,7 @@ export default {
         name: "",
         file: null,
       },
-      isAdd:'',isEdit:'',isResetpassword:'',isDelete:'',isEnable:'',isImport:'',isExport:''
+      isAdd:'',isEdit:'',isResetpassword:'',isDelete:'',isEnable:'',isImport:'',isExport:'',isSort:''
     }
   },
 
@@ -941,7 +941,8 @@ export default {
   },
   created() {
     this.getButton()
-    this.getList()
+    this.getList()
+    // this.getInforvalueList()
   },
 
   methods: {
@@ -958,6 +959,8 @@ export default {
       this.isImport = checkButtons(_import)
       const _export = 'rangeManagement:feedTable:export'
       this.isExport = checkButtons(_export)
+      const _sort = 'rangeManagement:feedTable:sort'
+      this.isSort = checkButtons(_sort)
     },
     getList() {
       this.table.listLoading = true
@@ -998,7 +1001,32 @@ export default {
         }, 1000)
       })
     },
-
+    getInforvalueList() {
+      let url = 'api/v1/ops/forage/small_material'
+      console.log(JSON.parse(sessionStorage.pastureList))
+      let pastureList = JSON.parse(sessionStorage.pastureList)
+      let idList = []
+      pastureList.forEach(item=>{
+        idList.push(item.id)
+      })
+      console.log(idList,'idList')
+      let data = {
+        "api_name": "getSysoptEnable",
+        "pasture_id": idList,
+        "info_name": "isSmallMaterial"
+      }
+      postJson(url,data).then(response => {
+        if (response.data !== null) {
+          if (response.data.list[0].inforvalue == 0) {
+            this.isInforvalue = false
+          } else {
+            this.isInforvalue = true
+          }
+        } else {
+          this.isInforvalue = false
+        }
+      })
+    },
     handleExport(item) {
       if (item == 1) {
         console.log('导出模板')
@@ -1674,28 +1702,17 @@ export default {
         var obj = {}
         obj.sort = i + 1
         obj.id = this.table.list[i].id
-        obj.pastureid = this.table.list[i].pastureid
         sortArr.push(obj)
       }
-      this.requestParam = {}
-      this.requestParam.common = { 'returnmap': '0' }
-      this.requestParam.data = []
-      this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': sortArr }}
-      this.requestParam.data[0].children = []
-      this.requestParam.data[0].children[0] = { 'name': 'updateFeedSort', 'type': 'e', 'parammaps': {
-        id: '@insertSpotList.id',
-        pastureid: '@insertSpotList.pastureid',
-        sort: '@insertSpotList.sort'
-      }}
-      ExecDataByConfig(this.requestParam).then(response => {
-        console.log('顺序切换保存发送参数', this.requestParam)
-        if (response.msg === 'fail') {
-          this.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
-        } else {
-          this.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
-          this.getList()
-          this.isOrder = true
-        }
+      let url = 'api/v1/ops/forage/sort'
+      let data = {
+        list:sortArr
+      }
+      postJson(url,data).then(response => {
+        if(response.code == 200){
+          this.$notify({ title: '成功', message: '成功', type: 'success', duration: 2000 })
+          this.getList()
+        }
       })
     },
     cancelChangeOrder() {