chenrui 4 years ago
parent
commit
62ca067710

+ 2 - 2
src/api/atorg.js

@@ -4,8 +4,8 @@ import { axios } from '@/utils/request'
 export const findOrgTree = params => {
   return axios({
     url: '/atorg/findOrgTree',
-    data: params,
-    method: 'post'
+    data: {},
+    method: 'get'
   })
 }
 // 保存

+ 5 - 6
src/api/login.js

@@ -3,16 +3,15 @@ import { axios } from '@/utils/request'
 
 export function login ({ username, password }) {
   return axios({
-    url: '/auth/login',
-    headers: { 'content-type': 'application/x-www-form-urlencoded', 'App-Type': 9 },
-    data: `username=${username}&password=${password}`,
+    url: 'auth/login',
+    data: { username, password },
     method: 'post'
-  }).then(res => res.data)
+  })
 }
 
 export function logout () {
   return axios({
-    url: '/auth/logout',
+    url: 'auth/logout',
     method: 'get'
   })
 }
@@ -57,7 +56,7 @@ export function get2step (parameter) {
 // 修改密码
 export function changePwd (parameter) {
   return axios({
-    url: 'user/changePWD',
+    url: '/user/changePWD',
     method: 'post',
     data: parameter
   })

+ 4 - 1
src/api/store.js

@@ -10,8 +10,11 @@ export const findStoreDetail = params => {
 }
 // 分页查询门店列表
 export const findStoreList = params => {
+  const url = `/store/findPage/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
   return axios({
-    url: '/store/findPage',
+    url: url,
     data: params,
     method: 'post'
   })

+ 4 - 29
src/store/modules/user.js

@@ -35,31 +35,6 @@ const user = {
   },
 
   actions: {
-    // 登录
-    // Login ({ commit }, userInfo) {
-    //   console.log(userInfo, 'userInfo----')
-    //   return new Promise((resolve, reject) => {
-    //     login(userInfo).then(res => {
-    //       console.log(res, 'login success')
-    //       if (res && res.userid) {
-    //         Vue.ls.set('hasError', 0)
-    //         commit('SET_TOKEN', res.userid)
-    //         commit('SET_NAME', { name: res.userNameCN, welcome: welcome() })
-    //         commit('SET_AVATAR', res.avatar ? res.avatar : '')
-    //         Vue.ls.set('rolesAccess', { permissionList: res.permCodes }, 7 * 24 * 60 * 60 * 1000)
-    //         // 记住密码
-    //         if (userInfo.rememberMe) {
-    //           VueCookies.set('REMEMBER_ME', JSON.stringify(userInfo))
-    //         } else {
-    //           VueCookies.remove('REMEMBER_ME')
-    //         }
-    //       }
-    //       resolve()
-    //     }).catch(error => {
-    //       reject(error)
-    //     })
-    //   })
-    // },
     // 登录
     Login ({ commit }, userInfo) {
       console.log(userInfo, 'userInfo----')
@@ -68,13 +43,13 @@ const user = {
           console.log(ret, 'login success')
           if (ret.status == 200) {
             const res = ret.data
-            if (ret.access_token && ret.auth_user) {
-              const users = ret.auth_user
+            if (res.access_token && res.auth_user) {
+              const users = res.auth_user
               Vue.ls.set('hasError', 0)
-              commit('SET_TOKEN', ret.access_token)
+              commit('SET_TOKEN', res.access_token)
               commit('SET_NAME', { name: users.userNameCN, welcome: welcome() })
               Vue.ls.set('rolesAccess', { permissionList: users.permCodes }, 7 * 24 * 60 * 60 * 1000)
-              // commit('SET_AVATAR', res.avatar ? res.avatar : '')
+              commit('SET_AVATAR', res.avatar ? res.avatar : '')
               // 记住密码
               if (userInfo.rememberMe) {
                 VueCookies.set('REMEMBER_ME', JSON.stringify(userInfo))

+ 34 - 37
src/utils/request.js

@@ -1,10 +1,11 @@
-import Vue from 'vue'
+// import Vue from 'vue'
 import axios from 'axios'
 import store from '@/store'
 import notification from 'ant-design-vue/es/notification'
+import modal from 'ant-design-vue/es/modal'
 import { VueAxios } from './axios'
-import { ACCESS_TOKEN } from '@/store/mutation-types'
-console.log(process.env.VUE_APP_PRO_NAME)
+// import { ACCESS_TOKEN } from '@/store/mutation-types'
+// console.log(process.env.VUE_APP_PRO_NAME)
 // 创建 axios 实例
 const service = axios.create({
   baseURL: process.env.VUE_APP_API_BASE_URL, // api base_url
@@ -12,19 +13,15 @@ const service = axios.create({
 })
 
 const err = (error) => {
+  console.log(error.response.data.message, 'error')
   if (error.response) {
-    const data = error.response.data
-    if ((error.response.status == 403 || error.response.status == 401) && window.location.pathname != '/user/login') {
+    const status = error.response.status
+    if ((status == 503 || status == 500) && window.location.pathname != '/user/login') {
       notification.destroy()
       notification.error({
         message: '提示',
-        description: data.message
+        description: error.response.data.message
       })
-      setTimeout(function () {
-        store.dispatch('Logout').then(() => {
-          window.location.reload()
-        })
-      }, 2000)
     }
   }
   // 超时无法访问服务
@@ -32,47 +29,47 @@ const err = (error) => {
     notification.destroy()
     notification.error({
       message: '提示',
-      description: error.message
+      description: '请求超时'
     })
-    setTimeout(function () {
-      store.dispatch('Logout').then(() => {
-        window.location.reload()
-      })
-    }, 2000)
   }
   return Promise.reject(error)
 }
 
 // request interceptor
 service.interceptors.request.use(config => {
-  const token = Vue.ls.get(ACCESS_TOKEN)
+  const token = store.getters.token
+  config.headers['App-Type'] = 1 // 平台类型
   if (token) {
-    // config.headers['Access-Token'] = token // 让每个请求携带自定义 token 请根据实际情况自行修改
+    config.headers['authorization'] = token // 让每个请求携带自定义 token 请根据实际情况自行修改
   }
   return config
 }, err)
 
 // response interceptor
 service.interceptors.response.use((response) => {
-  console.log(response, response.data.status, 'responseresponseresponse')
-  if (window.location.pathname != '/user/login') {
-    if (response.data.status == '900') {
-      notification.destroy()
-      notification.error({
-        message: '提示',
-        description: response.data.message
-      })
-    }
-  } else {
-    if (response.data.status == '500') {
-      notification.destroy()
-      notification.error({
-        message: '提示',
-        description: response.data.message
-      })
-    }
+  console.log(response, 'response.data.status')
+  const et = sessionStorage.getItem('errorTips')
+  if (response.data.status == '1001' && !et) {
+    sessionStorage.setItem('errorTips', 1)
+    modal.destroyAll()
+    modal.error({
+      title: '提示',
+      content: response.data.message,
+      onOk () {
+        sessionStorage.setItem('errorTips', 0)
+        store.dispatch('Logout').then(() => {
+          window.location.reload()
+        })
+      }
+    })
+  }
+  if ((response.data.status == '401' || response.data.status == '900' || response.data.status == '500') && window.location.pathname != '/user/login') {
+    notification.destroy()
+    notification.error({
+      message: '提示',
+      description: response.data.message
+    })
   }
-
   return response.data
 }, err)
 

+ 16 - 13
src/views/BasicSettings/Organization.vue

@@ -8,13 +8,14 @@
       ref="table"
       size="default"
       rowKey="id"
+      :showPagination="false"
       :columns="columns"
       :data="loadData"
       bordered>
       <!-- 操作 -->
       <template slot="action" slot-scope="text, record">
         <a-button
-          v-if="record.children"
+          v-if="record.parentIdPaths.split(',').length < 5"
           type="link"
           size="small"
           icon="plus"
@@ -74,9 +75,10 @@ export default {
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
-        return findOrgTree(Object.assign(parameter, {})).then(res => {
+        return findOrgTree().then(res => {
+          console.log(res.data)
           //  递归去除空children
-          this.recursionFun(res.data.list)
+          this.recursionFun(res.data)
           return res.data
         })
       },
@@ -96,10 +98,11 @@ export default {
     //  添加子级
     addOrg (item) {
       this.nowId = ''
+      this.form.name = ''
       if (item) { //  子级
         this.nowPid = item.id
       } else { //  最高级
-        this.nowPid = 0
+        this.nowPid = ''
       }
       this.title = '新增'
       this.visible = true
@@ -136,8 +139,6 @@ export default {
     },
     //  关闭对话框
     onCancel () {
-      //  重置表单数据
-      this.form.name = ''
       this.visible = false
     },
     //  删除
@@ -161,13 +162,15 @@ export default {
     },
     //  递归函数
     recursionFun (data) {
-      data.map(item => {
-        if (item.children && item.children.length == 0) {
-          delete item.children
-        } else {
-          this.recursionFun(item.children)
-        }
-      })
+      if (data) {
+        data.map(item => {
+          if (item.children && item.children.length == 0) {
+            delete item.children
+          } else {
+            this.recursionFun(item.children)
+          }
+        })
+      }
     }
   }
 }

+ 8 - 6
src/views/BasicSettings/StoreAssociatedEquipmentModal.vue

@@ -34,7 +34,7 @@
     </div>
     <!-- 已绑设备 -->
     <div class="eq-tit">已绑设备:</div>
-    <a-table
+    <s-table
       class="table"
       ref="table"
       bordered
@@ -42,25 +42,25 @@
       :row-key="id"
       :columns="columns"
       :data-source="equipmentData"
-      :pagination="false">
+      :showPagination="false">
       <div slot="expandedRowRender" slot-scope="record" style="margin: 30px 30px;">
         <div class="eq-subTit">设备通道(机位):</div>
-        <a-table
+        <s-table
           ref="tables"
           bordered
           size="small"
           :columns="passagewayColumns"
           :data-source="record.passageway"
-          :pagination="false">
+          :showPagination="false">
           <template slot="action" slot-scope="record">
             <a-button type="link" id="equipment-edit" @click="onEdit(record)">编辑</a-button>
           </template>
-        </a-table>
+        </s-table>
       </div>
       <template slot="action" slot-scope="record">
         <a-button type="primary" ghost size="small" id="equipment-unBind" @click="onUnbundling(record)">解绑</a-button>
       </template>
-    </a-table>
+    </s-table>
     <!-- 编辑  通道/机位名称 -->
     <a-modal
       class="passagewayModal"
@@ -85,9 +85,11 @@
 </template>
 
 <script>
+import { STable, VSelect } from '@/components'
 import { findStoreVsDevice, unbindVsDevice, findVsDevice, bindVsDevice } from '@/api/storeVsDevice.js'
 export default {
   name: 'StoreAssociatedEquipmentModal',
+  components: { STable, VSelect },
   props: {
     openModal: {
       //  弹框是否展示

+ 6 - 5
src/views/BasicSettings/StoreManagement.vue

@@ -65,7 +65,7 @@ import StoreAssociatedEquipmentModal from './StoreAssociatedEquipmentModal.vue'
 // import { getProvince, getCityByPro } from '@/api/lookup'
 import { findStoreList } from '@/api/store.js'
 export default {
-  name: 'CarWashManagement',
+  name: 'StoreManagement',
   components: { STable, VSelect, StoreModal, StoreAssociatedEquipmentModal },
   data () {
     return {
@@ -79,17 +79,18 @@ export default {
       columns: [
         { title: '序号', dataIndex: 'no', width: '100', align: 'center' },
         { title: '创建时间', dataIndex: 'createDate', width: '100', align: 'center' },
-        { title: '组织机构', dataIndex: 'orgCode', width: '100', align: 'center' },
+        { title: '组织机构', dataIndex: 'orgCodeName', width: '100', align: 'center' },
         { title: '门店名称', dataIndex: 'name', width: '100', align: 'center' },
         { title: '门店类型', dataIndex: 'type', width: '100', align: 'center' },
-        { title: '负责人名称', dataIndex: 'managerId', width: '100', align: 'center' },
+        { title: '负责人名称', dataIndex: 'managerName', width: '100', align: 'center' },
         { title: '负责人手机', dataIndex: 'managerMobile', width: '100', align: 'center' },
-        { title: '启用状态', dataIndex: 'enableFlag', width: '100', align: 'center' },
+        { title: '启用状态', dataIndex: 'isEnable', width: '100', align: 'center' },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '265', align: 'center' }
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
-        return findStoreList(Object.assign(parameter, this.queryParam)).then(res => {
+        return findStoreList(Object.assign(parameter, {})).then(res => {
+        // return findStoreList(Object.assign(parameter, this.queryParam)).then(res => {
           console.log(res)
           const no = (res.data.pageNo - 1) * res.data.pageSize
           for (let i = 0; i < res.data.list.length; i++) {

+ 26 - 18
src/views/BasicSettings/StoreModal.vue

@@ -30,7 +30,7 @@
         </a-col>
         <a-col :span="24" class="item-w">
           <div class="item-label">地址:</div>
-          <div class="item-cont">{{ storeInfo.addrProvinceName }} - {{ storeInfo.addrCityName }} - {{ storeInfo.addrDistrictName }} - {{ storeInfo.addrDetail }}</div>
+          <div class="item-cont">{{ storeInfo.addrProvinceName }}{{ storeInfo.addrCityName }}{{ storeInfo.addrDistrictName }}{{ storeInfo.addrDetail }}</div>
         </a-col>
         <a-col :span="8" class="item-w">
           <div class="item-label">纬度:</div>
@@ -63,7 +63,8 @@
               :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
               :tree-data="treeData"
               placeholder="请选择组织归属"
-              treeNodeFilterProp="title">
+              treeNodeFilterProp="title"
+              @change="treeChange">
             </a-tree-select>
           </a-form-model-item>
         </a-col>
@@ -107,6 +108,7 @@ export default {
         orgCode: [{ required: true, message: '请选择所属组织归属', trigger: 'change' }]
       },
       treeData: [],
+      parentCodePaths: '', //  机构编码父路径
       storeInfo: null //  门店详情
     }
   },
@@ -114,9 +116,9 @@ export default {
     //  门店详情
     getStoreInfo (id) {
       findStoreDetail({ id: id }).then(res => {
-        console.log(res, '————————')
         if (res.status == 200) {
           this.storeInfo = res.data
+          this.form.orgCode = res.data.orgCode
         }
       })
     },
@@ -124,7 +126,7 @@ export default {
     getOrgList () {
       findOrgTree().then(res => {
         if (res.status == 200) {
-          this.treeData = this.recursionFun(res.data.list)
+          this.treeData = this.recursionFun(res.data)
         } else {
           this.treeData = []
         }
@@ -132,28 +134,34 @@ export default {
     },
     //  递归函数
     recursionFun (data) {
-      data.map(item => {
-        if (item.children && item.children.length == 0) {
-          item.key = item.id ? 'org' + item.id : ''
-          item.value = item.id ? item.id : ''
-          item.title = item.name ? item.name : ''
-        } else {
-          item.key = item.id ? 'org' + item.id : ''
-          item.value = item.id ? item.id : ''
-          item.title = item.name ? item.name : ''
-          this.recursionFun(item.children)
-        }
-      })
+      if (data) {
+        data.map(item => {
+          if (item.children && item.children.length == 0) {
+            item.key = item.id ? 'org' + item.id : ''
+            item.value = item.code ? item.code : ''
+            item.title = item.name ? item.name : ''
+          } else {
+            item.key = item.id ? 'org' + item.id : ''
+            item.value = item.code ? item.code : ''
+            item.title = item.name ? item.name : ''
+            this.recursionFun(item.children)
+          }
+        })
+      }
       return data
     },
+    //  组织归属  change
+    treeChange (value, label, extra) {
+      this.parentCodePaths = extra.triggerNode.$options.propsData.dataRef.parentCodePaths
+    },
     //  保存
     onSubmit () {
       const _this = this
       _this.$refs.ruleForm.validate(valid => {
         if (valid) {
           const formData = JSON.parse(JSON.stringify(_this.form))
-          formData.tenantId = this.storeId
-          console.log(formData)
+          formData.id = this.storeId
+          formData.orgCodePaths = this.parentCodePaths
           saveStoreOrg(formData).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)

+ 2 - 2
vue.config.js

@@ -109,9 +109,9 @@ const vueConfig = {
     proxy: {
       '/api': {
         // target: 'http://carwash.test.zyucgj.com/cw-admin/',
-        // target: 'http://192.168.16.102:8101/cw-admin/',
         // target: 'https://carwash.test.zyucgj.com/cw-admin/',
-        target: 'http://192.168.16.107:7300/mock/5f5b0d9ecb0f492ad4ee85db/admin/at-admin/',
+        target: 'http://192.168.16.100:9102/at-admin/',
+        // target: 'http://192.168.16.107:7300/mock/5f5b0d9ecb0f492ad4ee85db/admin/at-admin/',
         ws: false,
         changeOrigin: true,
         pathRewrite: {