Browse Source

中心店/配送店绑定、用户授权

chenrui 4 years ago
parent
commit
8a969b1c8b

+ 8 - 0
src/api/jxsorg.js

@@ -11,6 +11,14 @@ export const jxsorgRelationList = (params) => {
     method: 'post'
   })
 }
+//  经销商 中心店/配送店绑定 列表 无分页
+export const jxsorgRelationQueryList = (params) => {
+  return axios({
+    url: '/jxsorg/relation/queryOrg',
+    data: params,
+    method: 'post'
+  })
+}
 // 经销商  中心店/配送店绑定  保存
 export const jxsorgRelationSave = (params) => {
   return axios({

+ 43 - 0
src/api/userOrg.js

@@ -0,0 +1,43 @@
+import { axios } from '@/utils/request'
+
+//  中心店用户授权 列表  有分页
+export const userOrgList = (params) => {
+  const url = `/userOrg/queryUserPage/${params.pageNo}/${params.pageSize}`
+  delete params.pageNo
+  delete params.pageSize
+  return axios({
+    url: url,
+    data: params,
+    method: 'post'
+  })
+}
+// 中心店用户授权  删除
+export const userOrgDel = (params) => {
+  return axios({
+    url: `/userOrg/deleteByUserSn/${params.sn}`,
+    method: 'get'
+  })
+}
+// 中心店用户授权  保存
+export const userOrgSave = (params) => {
+  return axios({
+    url: '/userOrg/saveUserOrg',
+    data: params,
+    method: 'post'
+  })
+}
+// 中心店用户授权  详情
+export const userOrgDetail = (params) => {
+  return axios({
+    url: `/userOrg/findByUserSn/${params.sn}`,
+    method: 'get'
+  })
+}
+//  中心店用户授权 账号  有分页
+export const userOrgUserList = (params) => {
+  return axios({
+    url: '/userOrg/queryUserByOrgSn',
+    data: params,
+    method: 'post'
+  })
+}

+ 25 - 0
src/config/router.config.js

@@ -1668,6 +1668,31 @@ export const asyncRouterMap = [
                 }
               }
             ]
+          },
+          {
+            path: '/storeManagement/userAuthorization',
+            redirect: '/storeManagement/userAuthorization/list',
+            name: 'storeManagementUserAuth',
+            component: RouteView,
+            meta: {
+              title: '中心店用户授权',
+              icon: 'link'
+              // permission: 'M_goodsManage_list'
+            },
+            hideChildrenInMenu: true,
+            children: [
+              {
+                path: 'list',
+                name: 'storeManagementUserAuthList',
+                component: () => import(/* webpackChunkName: "shop" */ '@/views/storeManagement/userAuthorization/list.vue'),
+                meta: {
+                  title: '中心店用户授权列表',
+                  icon: 'link',
+                  hidden: true
+                  // permission: 'M_goodsManage_list'
+                }
+              }
+            ]
           }
         ]
       },

+ 32 - 25
src/views/storeManagement/bind/editModal.vue

@@ -19,10 +19,10 @@
         :wrapper-col="formItemLayout.wrapperCol"
       >
         <a-form-model-item label="选择中心店" prop="orgSn">
-          <orgList ref="orgList" :disabled="itemSn?'*':''" @change="orgChange" />
+          <orgList ref="orgList" :disabled="itemSn?itemSn:''" @change="orgChange" />
         </a-form-model-item>
         <a-form-model-item label="选择配送店" prop="childSnList">
-          <orgList ref="orgLists" type="childOrg" :disabled="itemSn?'':form.orgSn" @change="orgsChange" />
+          <orgMultipleList ref="orgMultipleList" :disabled="itemSn?'':form.orgSn" @change="orgMultipleChange" />
         </a-form-model-item>
       </a-form-model>
       <div class="btn-cont">
@@ -36,10 +36,11 @@
 <script>
 import { STable } from '@/components'
 import orgList from './orgList.vue'
+import orgMultipleList from './orgMultipleList.vue'
 import { jxsorgRelationSave, jxsorgRelationDetail } from '@/api/jxsorg'
 export default {
   name: 'BindEditModal',
-  components: { STable, orgList },
+  components: { STable, orgList, orgMultipleList },
   props: {
     openModal: { //  弹框显示状态
       type: Boolean,
@@ -72,29 +73,23 @@ export default {
     }
   },
   methods: {
-    // 中心店 change
-    orgChange (obj) {
-      console.log(obj)
-      this.form.orgSn = obj.key || undefined
-    },
-    orgsChange (obj) {
-      console.log(obj)
-      const _this = this
-      this.form.childSnList = []
-      obj.map(item => {
-        _this.form.childSnList.push(item.key || undefined)
-      })
-    },
-    filterOption (input, option) {
-      return (
-        option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
-      )
-    },
     //  详情
     getDetail () {
+      const _this = this
       jxsorgRelationDetail({ sn: this.itemSn }).then(res => {
         if (res.status == 200) {
-          console.log(res.data, '+++++++')
+          _this.form.orgSn = res.data.orgSn || undefined
+          _this.$refs.orgList.fetchUser(res.data.orgName)
+          _this.$refs.orgList.dealerName = { key: res.data.orgSn }
+          const childSnList = []
+          if (res.data.childList) {
+            res.data.childList.map(item => {
+              childSnList.push({ key: item.sn })
+            })
+          }
+          _this.form.childSnList = childSnList.length == 0 ? undefined : childSnList
+          _this.$refs.orgMultipleList.setData(childSnList, res.data.childList || [])
+          _this.$refs.orgMultipleList.dealerName = childSnList
         }
       })
     },
@@ -110,8 +105,6 @@ export default {
               setTimeout(function () {
                 _this.isShow = false
               }, 300)
-            } else {
-
             }
           })
         } else {
@@ -119,6 +112,18 @@ export default {
           return false
         }
       })
+    },
+    // 中心店 change
+    orgChange (obj) {
+      this.form.orgSn = obj.key || undefined
+    },
+    // 配送店  change
+    orgMultipleChange (obj) {
+      const _this = this
+      this.form.childSnList = []
+      obj.map(item => {
+        _this.form.childSnList.push(item.key || undefined)
+      })
     }
   },
   watch: {
@@ -131,11 +136,13 @@ export default {
       if (!newValue) {
         this.$emit('close')
         this.$refs.ruleForm.resetFields()
+        this.form.childSnList = undefined
+        this.$refs.orgList.resetForm()
+        this.$refs.orgMultipleList.resetForm()
       }
     },
     itemSn (newValue, oldValue) {
       if (this.isShow && newValue) {
-        console.log(newValue)
         this.getDetail()
       }
     }

+ 6 - 11
src/views/storeManagement/bind/orgList.vue

@@ -7,14 +7,12 @@
     style="width: 100%"
     :filter-option="false"
     :not-found-content="fetching ? undefined : null"
-    :mode="type=='childOrg'?'multiple':'default'"
+    :disabled="disabled?true:false"
     @search="fetchUser"
     @change="handleChange"
-    :disabled="type=='childOrg'&&!disabled"
-    allowClear
-  >
+    allowClear>
     <a-spin v-if="fetching" slot="notFoundContent" size="small" />
-    <a-select-option v-for="item in data" :key="item.sn" :value="item.sn" :disabled="disabled==item.sn || item.status=='0'">
+    <a-select-option v-for="item in data" :key="item.sn" :value="item.sn">
       {{ item.name }}
     </a-select-option>
   </a-select>
@@ -27,10 +25,6 @@ export default {
     disabled: {
       type: [String, Number],
       default: ''
-    },
-    type: {
-      type: String,
-      default: 'default'
     }
   },
   data () {
@@ -38,7 +32,7 @@ export default {
     this.fetchUser = debounce(this.fetchUser, 800)
     return {
       data: [],
-      dealerName: [],
+      dealerName: undefined,
       fetching: false
     }
   },
@@ -67,7 +61,8 @@ export default {
       this.$emit('change', value || { key: undefined })
     },
     resetForm () {
-      this.dealerName = []
+      this.dealerName = undefined
+      this.data = []
     }
   }
 }

+ 75 - 0
src/views/storeManagement/bind/orgMultipleList.vue

@@ -0,0 +1,75 @@
+<template>
+  <a-select
+    show-search
+    label-in-value
+    :value="dealerName"
+    placeholder="请输入名称搜索"
+    style="width: 100%"
+    :filter-option="false"
+    :not-found-content="fetching ? undefined : null"
+    mode="multiple"
+    :disabled="disabled?true:false"
+    @search="fetchUser"
+    @change="handleChange"
+    allowClear
+  >
+    <a-spin v-if="fetching" slot="notFoundContent" size="small" />
+    <a-select-option v-for="item in data" :key="item.sn" :value="item.sn" :disabled="disabled==item.sn || item.status=='0'">
+      {{ item.name }}
+    </a-select-option>
+  </a-select>
+</template>
+<script>
+import debounce from 'lodash/debounce'
+import { jsxorgList } from '@/api/jxsorg'
+export default {
+  props: {
+    disabled: {
+      type: [String, Number],
+      default: ''
+    }
+  },
+  data () {
+    this.lastFetchId = 0
+    this.fetchUser = debounce(this.fetchUser, 800)
+    return {
+      data: [],
+      dealerName: [],
+      fetching: false
+    }
+  },
+  methods: {
+    fetchUser (dealerName) {
+      console.log('fetching user', dealerName)
+      if (dealerName == '') return
+      this.lastFetchId += 1
+      const fetchId = this.lastFetchId
+      this.data = []
+      this.fetching = true
+      jsxorgList({ 'name': dealerName, pageNo: 1, pageSize: 20 }).then(res => {
+        if (fetchId !== this.lastFetchId) {
+          return
+        }
+        this.data = res.data.list || []
+        this.fetching = false
+      })
+    },
+    handleChange (value) {
+      Object.assign(this, {
+        dealerName: value,
+        data: [],
+        fetching: false
+      })
+      this.$emit('change', value || { key: undefined })
+    },
+    resetForm () {
+      this.dealerName = []
+      this.data = []
+    },
+    setData (val, list) {
+      this.data = list
+      this.dealerName = val
+    }
+  }
+}
+</script>

+ 233 - 0
src/views/storeManagement/userAuthorization/editModal.vue

@@ -0,0 +1,233 @@
+<template>
+  <a-modal
+    centered
+    class="bindEdit-modal"
+    :footer="null"
+    :maskClosable="false"
+    title="账号授权"
+    v-model="isShow"
+    @cancle="isShow=false"
+    :width="800">
+    <!-- 表单 -->
+    <div>
+      <a-form-model
+        id="bindEdit-form"
+        ref="ruleForm"
+        :model="form"
+        :rules="rules"
+        :label-col="formItemLayout.labelCol"
+        :wrapper-col="formItemLayout.wrapperCol"
+      >
+        <a-form-model-item label="选择中心店" prop="ownerOrgSn">
+          <a-select
+            placeholder="请选择中心店"
+            id="productInfoList-ownerOrgSn"
+            allowClear
+            v-model="form.ownerOrgSn"
+            :showSearch="true"
+            option-filter-prop="children"
+            :filter-option="filterOption"
+            @change="orgChange">
+            <a-select-option v-for="item in orgList" :key="item.orgSn" :value="item.orgSn">{{ item.orgName }}</a-select-option>
+          </a-select>
+        </a-form-model-item>
+        <a-form-model-item label="选择授权账号" prop="userSn">
+          <a-select
+            placeholder="请选择授权账号"
+            id="productInfoList-userSn"
+            allowClear
+            v-model="form.userSn"
+            :showSearch="true"
+            option-filter-prop="children"
+            :filter-option="filterOption">
+            <a-select-option v-for="item in userList" :key="item.sn" :value="item.sn">{{ item.name }}</a-select-option>
+          </a-select>
+        </a-form-model-item>
+        <a-form-model-item label="选择配送店" prop="orgSnList">
+          <a-select
+            placeholder="请选择配送店"
+            id="productInfoList-orgSnList"
+            allowClear
+            v-model="form.orgSnList"
+            mode="multiple"
+            :showSearch="true"
+            option-filter-prop="children"
+            :filter-option="filterOption">
+            <a-select-option v-for="item in childList" :key="item.sn" :value="item.sn">{{ item.name }}</a-select-option>
+          </a-select>
+        </a-form-model-item>
+      </a-form-model>
+      <div class="btn-cont">
+        <a-button type="primary" id="bindEdit-modal-save" @click="handleSave">保存</a-button>
+        <a-button id="bindEdit-modal-back" @click="isShow = false" style="margin-left: 15px;">关闭</a-button>
+      </div>
+    </div>
+  </a-modal>
+</template>
+
+<script>
+import { STable } from '@/components'
+import { jxsorgRelationSave, jxsorgRelationDetail, jxsorgRelationQueryList } from '@/api/jxsorg'
+import { userOrgUserList, userOrgDetail, userOrgSave } from '@/api/userOrg'
+export default {
+  name: 'BindEditModal',
+  components: { STable },
+  props: {
+    openModal: { //  弹框显示状态
+      type: Boolean,
+      default: false
+    },
+    itemSn: {
+      type: [Number, String],
+      default: ''
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  是否打开弹框
+      formItemLayout: {
+        labelCol: { span: 6 },
+        wrapperCol: { span: 16 }
+      },
+      form: {
+        ownerOrgSn: undefined,
+        userSn: undefined,
+        orgSnList: undefined
+      },
+      rules: {
+        ownerOrgSn: [ { required: true, message: '请选择中心店', trigger: 'change' } ],
+        userSn: [ { required: true, message: '请选择授权账号', trigger: 'change' } ],
+        orgSnList: [ { required: true, message: '请选择配送店', trigger: 'change' } ]
+      },
+      orgList: [],
+      userList: [],
+      childList: []
+    }
+  },
+  methods: {
+    // 中心店 change
+    orgChange (val) {
+      this.getUserList()
+      this.getChildList()
+    },
+    filterOption (input, option) {
+      return (
+        option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
+      )
+    },
+    //  详情
+    getDetail () {
+      const _this = this
+      // userOrgDetail({ sn: this.itemSn }).then(res => {
+      //   if (res.status == 200) {
+      //     if (res.data.orgName) {
+      //       _this.$refs.orgList.fetchUser(res.data.orgName)
+      //       setTimeout(() => {
+      //         _this.$refs.orgList.dealerName = res.data.orgSn
+      //       }, 1000)
+      //     }
+      //     _this.form.orgSn = res.data.orgSn || undefined
+      //     const childSnList = []
+      //     if (res.data.childList) {
+      //       res.data.childList.map(item => {
+      //         childSnList.push(item.sn)
+      //       })
+      //     }
+      //     _this.form.childSnList = childSnList
+      //     _this.$refs.orgMultipleList.setData(childSnList)
+      //     _this.$refs.orgMultipleList.dealerName = childSnList
+      //   }
+      // })
+    },
+    //  保存
+    handleSave () {
+      const _this = this
+      this.$refs.ruleForm.validate(valid => {
+        if (valid) {
+          userOrgSave(_this.form).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$emit('ok')
+              setTimeout(function () {
+                _this.isShow = false
+              }, 300)
+            } else {
+
+            }
+          })
+        } else {
+          console.log('error submit!!')
+          return false
+        }
+      })
+    },
+    // 中心店数据
+    getOrgList () {
+      jxsorgRelationQueryList({}).then(res => {
+        if (res.status == 200) {
+          this.orgList = res.data
+        } else {
+          this.orgList = []
+        }
+      })
+    },
+    // 授权账号数据
+    getUserList () {
+      userOrgUserList({ orgSn: this.form.ownerOrgSn }).then(res => {
+        if (res.status == 200) {
+          if (res.status == 200) {
+            this.userList = res.data
+          } else {
+            this.userList = []
+          }
+        }
+      })
+    },
+    // 配送店数据
+    getChildList () {
+      jxsorgRelationDetail({ sn: this.form.ownerOrgSn }).then(res => {
+        if (res.status == 200) {
+          this.childList = res.data.childList || []
+        } else {
+          this.childList = []
+        }
+      })
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (newValue, oldValue) {
+      if (!newValue) {
+        this.$emit('close')
+        this.$refs.ruleForm.resetFields()
+        this.orgList = []
+        this.userList = []
+        this.childList = []
+      } else {
+        this.getOrgList()
+      }
+    },
+    itemSn (newValue, oldValue) {
+      if (this.isShow && newValue) {
+        this.getDetail()
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less">
+  .bindEdit-modal{
+    .ant-modal-body {
+    	padding: 40px 40px 24px;
+    }
+    .btn-cont {
+    	text-align: center;
+    	margin: 35px 0 10px;
+    }
+  }
+</style>

+ 145 - 0
src/views/storeManagement/userAuthorization/list.vue

@@ -0,0 +1,145 @@
+<template>
+  <a-card size="small" :bordered="false" class="userAuthList-wrap">
+    <!-- 搜索条件 -->
+    <div class="table-page-search-wrapper">
+      <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
+        <a-row :gutter="15">
+          <a-col :md="6" :sm="24">
+            <a-form-item label="中心店名称">
+              <a-input id="userAuthList-orgName" v-model.trim="queryParam.orgName" allowClear placeholder="请输入中心店名称"/>
+            </a-form-item>
+          </a-col>
+          <a-col :md="6" :sm="24">
+            <a-form-item label="中心店授权账号">
+              <a-input id="userAuthList-orgName" v-model.trim="queryParam.orgName" allowClear placeholder="请输入中心店授权账号"/>
+            </a-form-item>
+          </a-col>
+          <a-col :md="6" :sm="24">
+            <a-form-item label="配送店名称">
+              <a-input id="userAuthList-childName" v-model.trim="queryParam.childName" allowClear placeholder="请输入配送店名称"/>
+            </a-form-item>
+          </a-col>
+          <a-col :md="6" :sm="24">
+            <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="userAuthList-refresh">查询</a-button>
+            <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="userAuthList-reset">重置</a-button>
+          </a-col>
+        </a-row>
+      </a-form>
+    </div>
+    <!-- 操作按钮 -->
+    <div class="table-operator">
+      <a-button id="userAuthList-add" type="primary" class="button-error" @click="handleEdit()">新增</a-button>
+    </div>
+    <!-- 列表 -->
+    <s-table
+      class="sTable"
+      ref="table"
+      size="default"
+      :rowKey="(record) => record.orgSn"
+      :columns="columns"
+      :data="loadData"
+      :scroll="{ y: tableHeight }"
+      bordered>
+      <!-- 操作 -->
+      <template slot="action" slot-scope="text, record">
+        <a-button
+          size="small"
+          type="link"
+          class="button-info"
+          @click="handleEdit(record)"
+          id="userAuthList-edit-btn">编辑</a-button>
+        <a-button
+          size="small"
+          type="link"
+          class="button-error"
+          @click="handleDel(record)"
+          id="userAuthList-del-btn">删除</a-button>
+      </template>
+    </s-table>
+    <!-- 新增/编辑 -->
+    <storeManagement-user-auth-edit-modal :openModal="openModal" :nowData="nowData" :itemSn="itemSn" @ok="$refs.table.refresh(true)" @close="closeModal" />
+  </a-card>
+</template>
+
+<script>
+import { STable } from '@/components'
+import storeManagementUserAuthEditModal from './editModal.vue'
+import { userOrgList, userOrgDel } from '@/api/userOrg'
+export default {
+  components: { STable, storeManagementUserAuthEditModal },
+  data () {
+    return {
+      queryParam: { //  查询条件
+        orgName: '',
+        childName: ''
+      },
+      tableHeight: 0,
+      disabled: false, //  查询、重置按钮是否可操作
+      columns: [
+        { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
+        { title: '中心店名称', dataIndex: 'orgName', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
+        { title: '中心店授权账号', dataIndex: 'allChildsName', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
+        { title: '已绑配送店', dataIndex: 'allChildName', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
+        { title: '操作', scopedSlots: { customRender: 'action' }, align: 'center' }
+      ],
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        this.disabled = true
+        if (this.tableHeight == 0) {
+          this.tableHeight = window.innerHeight - 380
+        }
+        return userOrgList(Object.assign(parameter, this.queryParam)).then(res => {
+          const data = res.data
+          const no = (data.pageNo - 1) * data.pageSize
+          for (var i = 0; i < data.list.length; i++) {
+            data.list[i].no = no + i + 1
+          }
+          this.disabled = false
+          return data
+        })
+      },
+      openModal: false, //  新增编辑  弹框
+      itemSn: '', //  当前sn
+      nowData: null //  当前记录数据
+    }
+  },
+  methods: {
+    //  重置
+    resetSearchForm () {
+      this.queryParam.orgName = ''
+      this.queryParam.childName = ''
+      this.$refs.table.refresh(true)
+    },
+    //  新增/编辑
+    handleEdit (row) {
+      this.itemSn = row ? row.orgSn : null
+      this.nowData = row || null
+      this.openModal = true
+    },
+    //  关闭弹框
+    closeModal () {
+      this.itemSn = ''
+      this.openModal = false
+    },
+    //  删除
+    handleDel (row) {
+      const _this = this
+      this.$confirm({
+        title: '提示',
+        content: '删除后会直接解除原有的授权,确定删除吗?',
+        centered: true,
+        onOk () {
+          userOrgDel({
+            sn: row.orgSn
+          }).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$refs.table.refresh()
+            }
+          })
+        }
+      })
+    }
+  }
+}
+</script>