Просмотр исходного кода

v1.7.4版本接口调试完成

yuwenjun1997 2 лет назад
Родитель
Сommit
173af765c2

+ 11 - 12
.env.development

@@ -4,36 +4,35 @@ NODE_ENV = development
 ENV = 'development'
 
 # 测试地址 API接口
-VUE_APP_BASE_API = 'https://zplma-b.caimei365.com'
-# VUE_APP_BASE_API = 'http://192.168.2.68:8012'
+# VUE_APP_BASE_API = 'https://zplma-b.caimei365.com'
+VUE_APP_BASE_API = 'http://192.168.2.200:8012'
 # VUE_APP_BASE_API = 'http://192.168.2.67:8012'
 
 # 文件上传 API接口地址
-VUE_APP_UPLOAD_API='https://zplma-b.caimei365.com'
-# VUE_APP_UPLOAD_API='http://192.168.2.68:8012'
+# VUE_APP_UPLOAD_API='https://zplma-b.caimei365.com'
+VUE_APP_UPLOAD_API='http://192.168.2.200:8012'
 # VUE_APP_UPLOAD_API='http://192.168.2.67:8012'
 
-
 # 二维码生成链接location
 VUE_APP_BASE_SERVER = 'https://www-b.caimei365.com'
 
 # 消息接口地址 WebSocket
 VUE_APP_SOCKET_SERVER = 'wss://zplma-b.caimei365.com/websocket?sessionSource=zplm_admin'
-# VUE_APP_SOCKET_SERVER = 'ws://192.168.2.68:8012/websocket?sessionSource=zplm_admin'
+# VUE_APP_SOCKET_SERVER = 'ws://192.168.2.200:8012/websocket?sessionSource=zplm_admin'
 
 # 网站地址
-# VUE_APP_LOCAL = 'http://192.168.2.92:9527'
-VUE_APP_LOCAL = 'http://zplm-b.caimei365.com'
+VUE_APP_LOCAL = 'http://192.168.2.92:9527'
+# VUE_APP_LOCAL = 'http://zplm-b.caimei365.com'
 
 # 认证通页面
-# VUE_APP_WWW_HOST = 'https://192.168.2.92:8888'
-VUE_APP_WWW_HOST = 'https://zp-b.caimei365.com'
+VUE_APP_WWW_HOST = 'https://192.168.2.92:8888'
+# VUE_APP_WWW_HOST = 'https://zp-b.caimei365.com'
 
 # 支付
 # VUE_APP_PAY_LOCAL = 'http://192.168.2.67:18014'
 VUE_APP_PAY_LOCAL = 'http://zplm-b.caimei365.com'
 
 # 文件上传路径
-# VUE_APP_UPLOAD_DIR = 'dev/authFile/'
-VUE_APP_UPLOAD_DIR = 'beta/authFile/'
+VUE_APP_UPLOAD_DIR = 'dev/authFile/'
+# VUE_APP_UPLOAD_DIR = 'beta/authFile/'
 

+ 28 - 1
src/api/auth.js

@@ -28,6 +28,15 @@ export function fecthAuthList(params) {
   })
 }
 
+// 授权列表
+export function fecthAuthListAll(params) {
+  return request({
+    url: '/auth/listAll',
+    method: 'get',
+    params
+  })
+}
+
 // 添加品牌授权
 export function saveBrandAuth(data) {
   return request({
@@ -189,7 +198,7 @@ export function resetClubUserPassword(data) {
   })
 }
 
-// 重置密码
+// 设置明星机构
 export function setStarClub(data) {
   return request({
     url: '/auth/star',
@@ -197,3 +206,21 @@ export function setStarClub(data) {
     data
   })
 }
+
+// 获取可绑定机构列表
+export function fetchClubBindList(params) {
+  return request({
+    url: '/auth/club/bind/list',
+    method: 'get',
+    params
+  })
+}
+
+// 更换绑定机构
+export function clubUserBindSave(data) {
+  return request({
+    url: '/club/user/bind/save',
+    method: 'post',
+    data
+  })
+}

+ 28 - 1
src/api/product.js

@@ -9,7 +9,7 @@ export function getProdList(params) {
   })
 }
 
-// 添加商品
+// 添加设备
 export function saveProduct(data) {
   return request({
     url: '/auth/product/save',
@@ -18,6 +18,15 @@ export function saveProduct(data) {
   })
 }
 
+// 关联设备
+export function saveProductRelation(data) {
+  return request({
+    url: '/auth/product/save/relation',
+    method: 'post',
+    data
+  })
+}
+
 // 根据id获取商品信息
 export function getProductById(params) {
   return request({
@@ -150,3 +159,21 @@ export function fetchDetialBySnCode(params) {
     params
   })
 }
+
+// 根据类型获取设备sn码
+export function fetchProductSnListType(params) {
+  return request({
+    url: '/auth/product/sn/listSn',
+    method: 'get',
+    params
+  })
+}
+
+// 获取设备关联机构列表
+export function fetchDeviceAssClubList(data) {
+  return request({
+    url: '/auth/product/relation/list',
+    method: 'post',
+    data
+  })
+}

+ 23 - 7
src/views/components/AssociatedClubList/index.vue

@@ -6,10 +6,26 @@
         <el-input v-model="listQuery.authParty" placeholder="机构名称" size="mini" @keyup.enter.native="handleFilter" />
       </div>
       <div class="filter-control">
-        <el-button size="mini" type="primary">搜索</el-button>
+        <el-button size="mini" type="primary" @click="handleFilter">搜索</el-button>
       </div>
     </div>
-    <el-table :data="list" :show-header="false" border @selection-change="handleSelectionChange">
+    <el-table
+      v-if="height"
+      :data="list"
+      :show-header="false"
+      border
+      :height="height"
+      @selection-change="handleSelectionChange"
+    >
+      <el-table-column v-if="selection" type="selection" width="50" align="center" />
+      <el-table-column prop="authParty" />
+      <el-table-column v-if="control" width="100" align="center">
+        <template slot-scope="{ row }">
+          <slot name="control" :row="row" />
+        </template>
+      </el-table-column>
+    </el-table>
+    <el-table v-else :data="list" :show-header="false" border @selection-change="handleSelectionChange">
       <el-table-column v-if="selection" type="selection" width="50" align="center" />
       <el-table-column prop="authParty" />
       <el-table-column v-if="control" width="100" align="center">
@@ -27,11 +43,7 @@ export default {
   props: {
     list: {
       type: Array,
-      default: () => [
-        {
-          authParty: '测试机构名'
-        }
-      ]
+      default: () => []
     },
     deleted: {
       type: Boolean,
@@ -48,6 +60,10 @@ export default {
     detail: {
       type: Boolean,
       default: true
+    },
+    height: {
+      type: String,
+      default: ''
     }
   },
   data() {

+ 29 - 7
src/views/components/SncodeList/index.vue

@@ -9,9 +9,31 @@
         <el-button size="mini" type="primary">搜索</el-button>
       </div>
     </div>
-    <el-table :data="list" :show-header="false" border @selection-change="handleSelectionChange">
+    <el-table
+      v-if="height"
+      :data="list"
+      :show-header="false"
+      border
+      :height="height"
+      @selection-change="handleSelectionChange"
+    >
       <el-table-column v-if="selection" type="selection" width="50" align="center" />
-      <el-table-column prop="sncode" />
+      <!-- <el-table-column prop="sncode" /> -->
+      <el-table-column>
+        <template slot-scope="{ row }">{{ row }}</template>
+      </el-table-column>
+      <el-table-column v-if="control" width="100" align="center">
+        <template slot-scope="{ row }">
+          <slot name="control" :row="row" />
+        </template>
+      </el-table-column>
+    </el-table>
+    <el-table v-else :data="list" :show-header="false" border @selection-change="handleSelectionChange">
+      <el-table-column v-if="selection" type="selection" width="50" align="center" />
+      <!-- <el-table-column prop="sncode" /> -->
+      <el-table-column>
+        <template slot-scope="{ row }">{{ row }}</template>
+      </el-table-column>
       <el-table-column v-if="control" width="100" align="center">
         <template slot-scope="{ row }">
           <slot name="control" :row="row" />
@@ -27,11 +49,7 @@ export default {
   props: {
     list: {
       type: Array,
-      default: () => [
-        {
-          sncode: 'adgsadgsdag'
-        }
-      ]
+      default: () => []
     },
     deleted: {
       type: Boolean,
@@ -48,6 +66,10 @@ export default {
     detail: {
       type: Boolean,
       default: true
+    },
+    height: {
+      type: String,
+      default: ''
     }
   },
   data() {

+ 139 - 24
src/views/normal/club/device/bind.vue

@@ -1,21 +1,27 @@
 <template>
   <div class="page-form-container">
-    <el-form label-width="110px" :model="formData" :rules="rules">
+    <el-form ref="form" label-width="110px" :model="formData" :rules="rules">
       <el-form-item label="认证方式:">关联已认证设备</el-form-item>
       <el-form-item label="选设备SN码:" prop="sncodeType">
         <el-radio-group v-model="formData.sncodeType" size="mini">
           <el-radio :label="1">所有设备SN码</el-radio>
-          <el-radio :label="2">关联机构设备SN码</el-radio>
+          <el-radio :label="2">关联机构设备SN码</el-radio>
         </el-radio-group>
       </el-form-item>
-      <el-form-item label="SN码列表:" prop="sncodeList">
-        <el-checkbox-group v-model="formData.sncodeList" />
-        <el-button size="mini" type="primary" @click="dialogCodeListVisible = true">选择SN码</el-button>
+      <el-form-item label="SN码列表:" prop="snList">
+        <el-checkbox-group v-model="formData.snList" />
+        <el-button size="mini" type="primary" @click="onChooseCode">选择SN码</el-button>
       </el-form-item>
       <el-form-item>
-        <sncode-list class="sncode-list" :selection="false" :control="true">
-          <template #control>
-            <el-button size="mini" type="danger">删除</el-button>
+        <sncode-list
+          class="sncode-list"
+          :selection="false"
+          :control="true"
+          :list="filterSelectedCodeList"
+          @filter="onSelectCodeFilter"
+        >
+          <template #control="{ row }">
+            <el-button size="mini" type="danger" @click="onSelectCodeRemove(row)">删除</el-button>
           </template>
         </sncode-list>
       </el-form-item>
@@ -28,11 +34,19 @@
     </div>
 
     <!-- 选择sn码 -->
-    <el-dialog title="所有设备SN码" :visible.sync="dialogCodeListVisible" width="30%" :show-close="false">
-      <sncode-list :selection="true" :control="false" />
+    <el-dialog :title="dialogTextTip" :visible.sync="dialogCodeListVisible" width="30%" :show-close="false">
+      <sncode-list
+        v-if="dialogCodeListVisible"
+        :selection="true"
+        :control="false"
+        :list="filterCodeList"
+        height="280"
+        @filter="onCodeFilter"
+        @selected="onCodeChange"
+      />
       <div slot="footer" class="dialog-footer">
-        <el-button type="primary" size="mini" @click="dialogCodeListVisible = false">取 消</el-button>
-        <el-button type="primary" size="mini" @click="dialogCodeListVisible = false">确 定</el-button>
+        <el-button type="primary" size="mini" @click="onCodeCancel">取 消</el-button>
+        <el-button type="primary" size="mini" @click="onCodeConfirm">确 定</el-button>
       </div>
     </el-dialog>
   </div>
@@ -40,6 +54,8 @@
 
 <script>
 import { SncodeList } from '@/views/components'
+import { fetchProductSnList, fetchProductSnListType, saveProductRelation } from '@/api/product'
+import { getStorage } from '@/utils/storage'
 export default {
   components: {
     SncodeList
@@ -48,26 +64,125 @@ export default {
     return {
       dialogCodeListVisible: false,
       formData: {
+        authType: 2,
+        authId: '',
         sncodeType: 1,
-        sncodeList: []
+        snList: []
+      },
+      rules: {
+        snList: [{ type: 'array', required: true, message: 'SN码列表不能为空', trigger: ['change'] }]
       },
       listQuery: {
         sncode: ''
       },
-      sncodeList: [
-        {
-          sncode: 'sdalfjdsalg'
-        }
-      ],
-      rules: {
-        sncodeList: [{ type: 'array', required: true, message: 'SN码列表不能为空', trigger: ['change'] }]
-      }
+      codeList: [],
+      filterCodeList: [],
+      selectedCodeList: [],
+      selectedCodeListAll: [],
+      filterSelectedCodeList: []
+    }
+  },
+  computed: {
+    dialogTextTip() {
+      return this.formData.sncodeType === 1 ? '所有设备SN码' : '关联机构设备SN码'
+    }
+  },
+  watch: {
+    selectedCodeListAll(nval) {
+      this.formData.snList = nval
     }
   },
+  created() {
+    // 获取当前设备所属机构的id
+    this.formData.authId = getStorage('device-setting-authId')
+  },
   methods: {
-    submit() {},
-    onSncodeFilter() {},
-    handleSelectionChange() {}
+    // 选择sn码
+    onChooseCode() {
+      this.dialogCodeListVisible = true
+      if (this.formData.sncodeType === 1) {
+        this.fetchSnCodeListAll()
+      } else {
+        this.fetchSnCodeListSelf()
+      }
+    },
+    // 获取全部sn码列表
+    async fetchSnCodeListSelf() {
+      try {
+        const res = await fetchProductSnListType({ authId: this.formData.authId })
+        if (!res.data) return
+        this.codeList = res.data.filter((code) => !this.selectedCodeListAll.includes(code))
+        this.filterCodeList = this.codeList
+        console.log(res)
+      } catch (error) {
+        console.log(error)
+      }
+    },
+    // 获取关联机构sn码列表
+    async fetchSnCodeListAll() {
+      try {
+        const res = await fetchProductSnList({ authId: this.formData.authId })
+        if (!res.data) return
+        this.codeList = res.data.filter((code) => !this.selectedCodeListAll.includes(code))
+        this.filterCodeList = this.codeList
+        console.log(res)
+      } catch (error) {
+        console.log(error)
+      }
+    },
+    // 保存
+    async onSave() {
+      try {
+        await saveProductRelation(this.formData)
+        this.$message.success('关联已认证设备成功')
+        this.$store.dispatch('tagsView/delView', this.$route)
+        this.$router.push(`/club/device-list?id=${this.formData.authId}`)
+      } catch (error) {
+        console.log(error)
+      }
+    },
+    // 提交表单
+    async submit() {
+      try {
+        await this.$refs.form.validate()
+        this.onSave()
+      } catch (error) {
+        console.log(error)
+      }
+    },
+    // 筛选sn码列表
+    onCodeFilter(query) {
+      this.filterCodeList = this.codeList.filter((code) => new RegExp(query.sncode, 'gi').test(code))
+    },
+    // 选中sn码
+    onCodeChange(value) {
+      this.selectedCodeList = value
+    },
+    // 取消选择sn码
+    onCodeCancel() {
+      this.selectedCodeListAll = [...this.selectedCodeListAll, ...this.selectedCodeList]
+      this.selectedCodeList = []
+      this.filterCodeList = []
+      this.dialogCodeListVisible = false
+    },
+    // 确认选择sn码
+    onCodeConfirm() {
+      this.selectedCodeListAll = [...this.selectedCodeListAll, ...this.selectedCodeList]
+      this.filterSelectedCodeList = this.selectedCodeListAll
+      this.filterCodeList = []
+      this.dialogCodeListVisible = false
+    },
+    // 已选中sn码筛选
+    onSelectCodeFilter(query) {
+      this.filterSelectedCodeList = this.filterSelectedCodeList.filter((code) =>
+        new RegExp(query.sncode, 'gi').test(code)
+      )
+    },
+    // 已选中sn码删除
+    onSelectCodeRemove(row) {
+      this.selectedCodeListAll = this.selectedCodeListAll.filter((code) => code !== row)
+      this.filterSelectedCodeList = this.selectedCodeListAll
+    }
   }
 }
 </script>

+ 29 - 4
src/views/normal/club/device/edit.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="device-edit page-form-container">
-    <el-form label-width="130px" :model="formData" :rules="rules">
+    <el-form ref="form" label-width="130px" :model="formData" :rules="rules">
       <el-form-item label="认证方式:">
         <span>{{ authTypeName }}</span>
       </el-form-item>
@@ -63,7 +63,7 @@
 
 <script>
 import UploadImage from '@/components/UploadImage'
-import { fetchProductSelectList, getProductById } from '@/api/product'
+import { fetchProductSelectList, getProductById, saveProduct } from '@/api/product'
 import { isSnCode } from '@/utils/validate'
 import { getStorage } from '@/utils/storage'
 export default {
@@ -120,7 +120,32 @@ export default {
   },
   methods: {
     // 提交
-    submit() {},
+    async submit() {
+      try {
+        await this.$refs.form.validate()
+        this.onSave()
+      } catch (error) {
+        console.log(error)
+      }
+    },
+
+    // 保存
+    async onSave() {
+      try {
+        await saveProduct(this.formData)
+        const h = this.$createElement
+        const tip = this.editType === 'add' ? '添加' : '修改'
+        this.$notify.success({
+          title: tip + '设备',
+          message: h('i', { style: 'color: #333' }, `已${tip}设备`),
+          duration: 2000
+        })
+        this.$store.dispatch('tagsView/delView', this.$route)
+        this.$router.push(`/club/device-list?id=${this.formData.authId}`)
+      } catch (error) {
+        console.log(error)
+      }
+    },
 
     // 获取设备信息
     async fetchProductDetail() {
@@ -136,7 +161,7 @@ export default {
 
     // 初始化表单数据
     initFormData(data) {
-      for (const key in data) {
+      for (const key in this.formData) {
         if (Object.hasOwnProperty.call(data, key)) {
           if (key === 'productTypeId') {
             this.formData[key] = parseInt(data[key])

+ 49 - 14
src/views/normal/club/device/index.vue

@@ -29,9 +29,11 @@
       </div>
       <div class="filter-control">
         <permission-button type="primary" @click="handleFilter">查询</permission-button>
-        <!-- <permission-button type="primary" @click="navigationTo(`device-add?type=add`)">添加</permission-button> -->
-        <permission-button type="primary" @click="navigationTo(`device-add?type=add`)">添加新设备认证</permission-button>
-        <permission-button type="primary" @click="navigationTo(`device-add?type=add`)">关联已认证设备</permission-button>
+        <permission-button
+          type="primary"
+          @click="navigationTo(`device-add?type=add`)"
+        >添加新设备认证</permission-button>
+        <permission-button type="primary" @click="navigationTo(`device-bind`)">关联已认证设备</permission-button>
       </div>
     </div>
     <!-- 表格区域 -->
@@ -96,7 +98,9 @@
             二维码
           </permission-button>
           <permission-button v-else type="info" size="mini" disabled> 二维码 </permission-button>
-          <permission-button type="primary" size="mini" @click="dialogClubVisible = true"> 其他关联机构 </permission-button>
+          <permission-button type="primary" size="mini" @click="fetchDeviceAssClubList(row)">
+            其他关联机构
+          </permission-button>
           <permission-button type="danger" size="mini" @click="handleRemoveProduct(row)"> 删除 </permission-button>
         </template>
       </el-table-column>
@@ -112,9 +116,15 @@
 
     <!-- 关联机构 -->
     <el-dialog title="其他关联机构" :visible.sync="dialogClubVisible" width="30%">
-      <associated-club-list class="associated-club-list" :selection="false" :control="true">
-        <template #control>
-          <el-button size="mini" type="primary">查看</el-button>
+      <associated-club-list
+        class="associated-club-list"
+        :selection="false"
+        :control="true"
+        height="300"
+        :list="assClubList"
+      >
+        <template #control="{ row }">
+          <el-button size="mini" type="primary" @click="onToClubDetail(row)">查看</el-button>
         </template>
       </associated-club-list>
     </el-dialog>
@@ -122,7 +132,7 @@
 </template>
 
 <script>
-import { getProdList, setProductStatus, removeProduct } from '@/api/product'
+import { getProdList, setProductStatus, removeProduct, fetchDeviceAssClubList } from '@/api/product'
 import { AssociatedClubList } from '@/views/components/index'
 import QrcodeDevice from '@/components/QrcodeDevice'
 import { mapGetters } from 'vuex'
@@ -151,7 +161,8 @@ export default {
       // 审核未通过
       auditFailedList: [],
       auditNoticeFlag: true,
-      dialogClubVisible: false
+      dialogClubVisible: false,
+      assClubList: []
     }
   },
   computed: {
@@ -166,6 +177,26 @@ export default {
   },
 
   methods: {
+    // 机构详情
+    onToClubDetail(row) {
+      this.dialogClubVisible = false
+      const fullPath = `/club/device-list?id=${row.authId}`
+      this.$router.replace({
+        path: '/redirect' + fullPath
+      })
+    },
+
+    // 获取设备关联机构列表
+    async fetchDeviceAssClubList(row) {
+      try {
+        const res = await fetchDeviceAssClubList({ snCode: row.snCode })
+        this.assClubList = res.data
+        this.dialogClubVisible = true
+      } catch (error) {
+        console.log(error)
+      }
+    },
+
     // 获取列表信息
     getList() {
       getProdList(this.listQuery)
@@ -207,11 +238,15 @@ export default {
     },
     // 删除商品
     async handleRemoveProduct(item) {
-      const text = await this.$confirm('此操作将删除该商品, 是否继续?', '提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning'
-      }).catch(() => {
+      const text = await this.$confirm(
+        '确定删除该设备认证吗?删除后,其他机构已关联此设备认证的也将一并删除,请慎重操作。',
+        '提示',
+        {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }
+      ).catch(() => {
         this.$message.info('已取消操作')
       })
       if (text !== 'confirm') return

+ 107 - 15
src/views/normal/club/edit.vue

@@ -176,12 +176,17 @@
       </template>
 
       <el-form-item label="已关联机构:">
-        <el-button size="mini" type="primary">关联机构</el-button>
+        <el-button size="mini" type="primary" @click="onChooseAssClub">关联机构</el-button>
       </el-form-item>
       <el-form-item>
-        <associated-club-list :selection="false" :control="true">
-          <template #control>
-            <el-button size="mini" type="danger">删除</el-button>
+        <associated-club-list
+          :selection="false"
+          :control="true"
+          :list="filterSelectAssClubList"
+          @filter="onFilterSelectAssClubList"
+        >
+          <template #control="{ row }">
+            <el-button size="mini" type="danger" @click="onAssClubListRemove(row)">删除</el-button>
           </template>
         </associated-club-list>
       </el-form-item>
@@ -207,11 +212,19 @@
     </el-dialog>
 
     <!-- 关联机构 -->
-    <el-dialog title="添加关联机构" :visible.sync="dialogClubVisible" width="30%" :show-close="false">
-      <associated-club-list :selection="true" :control="false" />
+    <el-dialog title="添加关联机构" :visible.sync="assClubListVisible" width="30%" :show-close="false">
+      <associated-club-list
+        v-if="assClubListVisible"
+        :selection="true"
+        :control="false"
+        height="280"
+        :list="assClubList"
+        @filter="onFilterAssClubList"
+        @selected="onAssClubListChange"
+      />
       <div slot="footer" class="dialog-footer">
-        <el-button type="primary" size="mini" @click="dialogClubVisible = false">取 消</el-button>
-        <el-button type="primary" size="mini" @click="dialogClubVisible = false">确 定</el-button>
+        <el-button type="primary" size="mini" @click="onAssClubListCancel">取 消</el-button>
+        <el-button type="primary" size="mini" @click="onAssClubListConfirm">确 定</el-button>
       </div>
     </el-dialog>
   </div>
@@ -222,7 +235,7 @@ import SimpleAMap from '@/components/SimpleAMap'
 import UploadImage from '@/components/UploadImage'
 import { AssociatedClubList } from '@/views/components/index'
 import { mapGetters } from 'vuex'
-import { saveBrandAuth, getAuthFormData } from '@/api/auth'
+import { saveBrandAuth, getAuthFormData, fecthAuthList } from '@/api/auth'
 import { getAddress } from '@/api/common'
 import { isPoint, isMobile, isNumber } from '@/utils/validate'
 import { formatDate } from '@/utils'
@@ -274,13 +287,12 @@ export default {
       value: [],
       options: [],
 
-      dialogClubVisible: true,
+      assClubListVisible: false,
 
       authId: '',
       disabled: false,
       area: '',
       formData: {
-        relationId: '',
         authParty: '',
         address: [],
         fullAddress: '',
@@ -303,7 +315,10 @@ export default {
         authImage: '',
         // 新增运营人字段
         linkMan: '',
-        linkMobile: ''
+        linkMobile: '',
+        // 机构关联
+        relationId: '',
+        relationName: ''
       },
       rules: {
         authParty: [{ required: true, message: '机构名称不能为空', trigger: ['blur', 'change'] }],
@@ -335,7 +350,17 @@ export default {
       validatorFields: {
         authImageLogoWidth: 100,
         authImageLogoHeight: 100
-      }
+      },
+      // 关联机构相关
+      assClubQuery: {
+        pageNum: 1,
+        pageSize: 1000,
+        authParty: ''
+      },
+      assClubList: [], // 关联机构列表
+      selectAssClubList: [], // 当前选中关联机构列表
+      selectAssClubListAll: [], // 全部选中关联机构列表
+      filterSelectAssClubList: [] // 筛选后的关联机构列表
     }
   },
   computed: {
@@ -376,9 +401,67 @@ export default {
     this.editType = this.$route.query.type || 'add'
     this.authId = this.$route.query.id
     this.initFormData()
-    this.fetchAuthTempUsed()
   },
   methods: {
+    // 关联机构选择
+    onChooseAssClub() {
+      this.fetchAssClubList()
+      this.assClubListVisible = true
+    },
+    // 获取关联机构列表
+    async fetchAssClubList() {
+      try {
+        const excludeId = this.selectAssClubListAll.map((item) => item.authId)
+        if (this.authId) {
+          excludeId.push(parseInt(this.authId))
+        }
+        const res = await fecthAuthList(this.assClubQuery)
+        this.assClubList = res.data.list.filter((item) => !excludeId.includes(item.authId))
+      } catch (error) {
+        console.log(error)
+      }
+    },
+    // 关联机构列表筛选
+    onFilterAssClubList(query) {
+      this.assClubQuery.authParty = query.authParty
+      this.fetchAssClubList()
+    },
+    // 关联机构列表选中
+    onAssClubListChange(value) {
+      this.selectAssClubList = value
+    },
+    // 关联机构选中列表确认
+    onAssClubListConfirm() {
+      this.selectAssClubListAll = [...this.selectAssClubListAll, ...this.selectAssClubList]
+      this.filterSelectAssClubList = this.selectAssClubListAll
+      this.assClubQuery.authParty = ''
+      this.assClubList = []
+      this.assClubListVisible = false
+    },
+    // 关联机构选中列表取消
+    onAssClubListCancel() {
+      this.selectAssClubList = []
+      this.filterSelectAssClubList = this.selectAssClubListAll
+      this.assClubQuery.authParty = ''
+      this.assClubList = []
+      this.assClubListVisible = false
+    },
+    // 已关联机构列表筛选
+    onFilterSelectAssClubList(query) {
+      if (query.authParty) {
+        this.filterSelectAssClubList = this.selectAssClubListAll.filter((item) =>
+          new RegExp(query.authParty, 'ig').test(item.authParty)
+        )
+      } else {
+        this.filterSelectAssClubList = this.selectAssClubListAll
+      }
+    },
+    // 已关联机构列表删除
+    onAssClubListRemove(row) {
+      this.selectAssClubListAll = this.selectAssClubListAll.filter((item) => item.authId !== row.authId)
+      this.filterSelectAssClubList = this.selectAssClubListAll
+    },
+
     // 地图定位
     initMap() {
       this.dialogMapVisible = true
@@ -418,6 +501,7 @@ export default {
         this.formData.logo = res.data.logo || ''
         this.formData.banner = res.data.bannerList.length || ''
         this.formData.relationId = res.data.relationId
+        this.formData.relationName = res.data.relationName
 
         this.formData.customFlag = res.data.customFlag
         this.formData.remarks = res.data.remarks
@@ -464,6 +548,12 @@ export default {
         // 运营人相关
         this.formData.linkMan = res.data.linkMan
         this.formData.linkMobile = res.data.linkMobile
+
+        // 关联机构列表
+        if (res.data.releationClubList) {
+          this.selectAssClubListAll = res.data.releationClubList
+          this.filterSelectAssClubList = this.selectAssClubListAll
+        }
       })
     },
 
@@ -520,7 +610,9 @@ export default {
           authImageLogo,
           authImage,
           linkMan,
-          linkMobile
+          linkMobile,
+          relationId: this.selectAssClubListAll.map((item) => item.authId).join(','),
+          relationName: this.selectAssClubListAll.map((item) => item.authParty).join(',')
         }
 
         data.bannerList = this.bannerList.map((item) => (item.response ? item.response.data : item.url))

+ 11 - 10
src/views/normal/club/index.vue

@@ -29,11 +29,11 @@
       </div>
       <div class="filter-control">
         <span>设备名称:</span>
-        <el-input v-model="listQuery.productName" placeholder="设备名称" @keyup.enter.native="handleFilter" />
+        <el-input v-model="listQuery.name" placeholder="设备名称" @keyup.enter.native="handleFilter" />
       </div>
       <div class="filter-control">
         <span>设备SN码:</span>
-        <el-input v-model="listQuery.sncode" placeholder="设备SN码" @keyup.enter.native="handleFilter" />
+        <el-input v-model="listQuery.snCode" placeholder="设备SN码" @keyup.enter.native="handleFilter" />
       </div>
       <div class="filter-control">
         <permission-button type="primary" @click="getList">查询</permission-button>
@@ -105,7 +105,7 @@
         <template slot-scope="{ row }">
           <div class="star-sort">
             <el-checkbox v-model="row.starFlag" :true-label="1" :false-label="0" @change="onStarChange(row, $event)" />
-            <el-input placeholder="排序" size="mini" />
+            <el-input v-model="row.starNum" placeholder="排序" size="mini" @blur="onStarChange(row, row.starFlag)" />
           </div>
         </template>
       </el-table-column>
@@ -182,7 +182,7 @@
 import FileUpload from '@/components/FileUpload'
 import QrcodeClub from '@/components/QrcodeClub'
 import { ClubListSelector } from '@/views/components'
-import { fecthAuthList, changeAuthStatus, removeAuth, authImportExcel, setStarClub } from '@/api/auth'
+import { fecthAuthListAll, changeAuthStatus, removeAuth, authImportExcel, setStarClub } from '@/api/auth'
 import { mapGetters } from 'vuex'
 import { debounce, downloadWithUrl } from '@/utils/tools'
 import handleClipboard from '@/utils/clipboard'
@@ -207,8 +207,8 @@ export default {
         pageSize: 10, // 分页
         status: '',
         starFlag: null,
-        productName: '',
-        sncode: ''
+        name: '',
+        snCode: ''
       },
 
       improtDialogVisible: false,
@@ -252,8 +252,9 @@ export default {
     async onStarChange(row, value) {
       console.log(row)
       try {
-        await setStarClub({ authId: row.authId, starFlag: value })
+        await setStarClub({ authId: row.authId, starFlag: value, starNum: row.starNum })
         this.$message.success('操作成功')
+        this.getList()
       } catch (error) {
         console.log(error)
       }
@@ -444,7 +445,7 @@ export default {
     getList() {
       console.log(this.listQuery)
       this.listLoading = true
-      fecthAuthList(this.listQuery)
+      fecthAuthListAll(this.listQuery)
         .then((response) => {
           if (response.code !== 0) {
             return this.$message.error('授权列表信息获取失败')
@@ -541,12 +542,12 @@ export default {
 </script>
 
 <style lang="scss" scoped>
-.star-sort{
+.star-sort {
   display: flex;
   align-items: center;
   justify-content: center;
 
-  .el-input{
+  .el-input {
     width: 50%;
     margin-left: 16px;
   }

+ 59 - 12
src/views/normal/user/index.vue

@@ -112,17 +112,18 @@
 
     <!-- 绑定/更换机构 -->
     <el-dialog title="绑定/更换机构" :visible.sync="dialogChangeClubVisible" width="30%" :show-close="false">
-      <el-form :model="changeClubForm" :rules="changeClubRules" label-width="70px">
-        <el-form-item prop="clubId" label="机构:">
-          <el-select v-model="changeClubForm.select" placeholder="请选择机构" style="width:100%">
-            <el-option label="机构A" value="1" />
-            <el-option label="机构B" value="2" />
+      <el-form ref="changeClubForm" :model="changeClubForm" :rules="changeClubRules" label-width="70px">
+        <el-form-item prop="authId" label="机构:">
+          <el-select v-model="changeClubForm.authId" placeholder="请选择机构" style="width: 100%" clearable>
+            <template v-for="item in bindClubList">
+              <el-option :key="item.authId" :label="item.authParty" :value="item.authId" />
+            </template>
           </el-select>
         </el-form-item>
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button type="primary" @click="dialogChangeClubVisible = false">取 消</el-button>
-        <el-button type="primary" @click="dialogChangeClubVisible = false">确 定</el-button>
+        <el-button type="primary" @click="onBindClubConfirm">确 定</el-button>
       </div>
     </el-dialog>
   </div>
@@ -130,7 +131,14 @@
 
 <script>
 import { mapGetters } from 'vuex'
-import { authUserStatusChange, createClubUser, getAuthUserList, resetClubUserPassword } from '@/api/auth'
+import {
+  authUserStatusChange,
+  clubUserBindSave,
+  createClubUser,
+  fetchClubBindList,
+  getAuthUserList,
+  resetClubUserPassword
+} from '@/api/auth'
 import { isMobile } from '@/utils/validate'
 
 const resetFormData = () => ({
@@ -176,11 +184,14 @@ export default {
         ]
       },
       changeClubForm: {
-        clubId: ''
+        clubUserId: '',
+        authId: '',
+        authParty: ''
       },
       changeClubRules: {
-        clubId: [{ required: true, message: '请选择机构', trigger: ['change'] }]
-      }
+        authId: [{ required: true, message: '请选择机构', trigger: ['change'] }]
+      },
+      bindClubList: []
     }
   },
   computed: {
@@ -191,8 +202,44 @@ export default {
   },
   methods: {
     // 更换机构
-    onChangeClub(row) {
-      this.dialogChangeClubVisible = true
+    async onChangeClub(row) {
+      try {
+        this.changeClubForm.clubUserId = row.clubUserId
+        const res = await fetchClubBindList()
+        console.log(res)
+        this.bindClubList = res.data
+        this.dialogChangeClubVisible = true
+      } catch (error) {
+        console.log(error)
+      }
+    },
+
+    // 绑定机构确定
+    async onBindClubConfirm() {
+      try {
+        const bindClub = this.bindClubList.find((item) => item.authId === this.changeClubForm.authId)
+        if (bindClub) {
+          this.changeClubForm.authParty = bindClub.authParty
+        }
+        await this.$refs.changeClubForm.validate()
+        this.onBindClub()
+      } catch (error) {
+        console.log(error)
+      }
+    },
+
+    // 绑定机构
+    async onBindClub() {
+      try {
+        await clubUserBindSave(this.changeClubForm)
+        this.dialogChangeClubVisible = false
+        this.getList()
+        this.$message.success('机构绑定成功!')
+      } catch (error) {
+        console.log(error)
+      } finally {
+        this.$refs.changeClubForm.resetFields()
+      }
     },
 
     // 更新列表