chenrui 4 years ago
parent
commit
6e10d2c53f

+ 1 - 1
src/api/vsDevice.js

@@ -11,7 +11,7 @@ export const vsDeviceChannels = params => {
 // 设备重命名
 export const vsDeviceRename = params => {
   return axios({
-    url: `/vs/device/rename/${params.id}/${params.name}`,
+    url: `/vs/device/rename/${params.deviceId}/${params.deviceName}`,
     data: {},
     method: 'get'
   })

+ 0 - 1
src/views/BasicSettings/Organization.vue

@@ -76,7 +76,6 @@ export default {
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
         return findOrgTree().then(res => {
-          console.log(res.data)
           //  递归去除空children
           this.recursionFun(res.data)
           return res.data

+ 67 - 37
src/views/BasicSettings/StoreAssociatedEquipmentModal.vue

@@ -40,19 +40,21 @@
       ref="table"
       bordered
       size="small"
-      :row-key="id"
+      :rowKey="(record) => record.id"
       :columns="columns"
       :data-source="equipmentData"
-      :showPagination="false">
+      :pagination="false"
+      @expand="eqExpand">
       <div slot="expandedRowRender" slot-scope="record" style="margin: 30px 30px;">
         <div class="eq-subTit">设备通道(机位):</div>
         <a-table
           ref="tables"
           bordered
           size="small"
+          :rowKey="(record) => record.gbId"
           :columns="passagewayColumns"
-          :data-source="record.passageway"
-          :showPagination="false">
+          :data-source="passagewayData"
+          :pagination="false">
           <template slot="action" slot-scope="record">
             <a-button type="link" id="equipment-edit" @click="onEdit(record)">编辑</a-button>
           </template>
@@ -73,8 +75,8 @@
       width="600px">
       <!-- 表单 -->
       <a-form-model ref="ruleForm" :model="form" :rules="rules">
-        <a-form-model-item label="名称" prop="name">
-          <a-input v-model.trim="form.name" id="equipment-name" :maxLength="30" placeholder="请输入名称,30个字以内" />
+        <a-form-model-item label="名称" prop="deviceName">
+          <a-input v-model.trim="form.deviceName" id="equipment-name" :maxLength="30" placeholder="请输入名称,30个字以内" />
         </a-form-model-item>
         <a-form-model-item class="btn-cont">
           <a-button type="primary" id="equipment-save" @click="onSubmit">保存</a-button>
@@ -86,12 +88,10 @@
 </template>
 
 <script>
-import { STable, VSelect } from '@/components'
 import { findStoreVsDevice, unbindVsDevice, findVsDevice, bindVsDevice } from '@/api/storeVsDevice.js'
 import { vsDeviceChannels, vsDeviceRename } from '@/api/vsDevice.js'
 export default {
   name: 'StoreAssociatedEquipmentModal',
-  components: { STable, VSelect },
   props: {
     openModal: {
       //  弹框是否展示
@@ -119,38 +119,46 @@ export default {
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '265', align: 'center' }
       ],
       equipmentData: [], //  已绑设备
+      passagewayData: [], //  设备通道
       passagewayColumns: [
         { title: '序号', dataIndex: 'no', width: '100', align: 'center' },
-        { title: '设备名称', dataIndex: 'name', width: '100', align: 'center' },
-        { title: '设备ID', dataIndex: 'id', width: '100', align: 'center' },
+        { title: '设备通道名称', dataIndex: 'name', width: '100', align: 'center' },
+        { title: '设备ID', dataIndex: 'deviceId', width: '100', align: 'center' },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '265', align: 'center' }
       ],
       visible: false, //  编辑  通道/机位名称
       form: {
-        name: '' //  名称
+        deviceName: '' //  名称
       },
       rules: { //  表单校验规则
-        name: [{ required: true, message: '请输入名称', trigger: 'blur' }]
+        deviceName: [{ required: true, message: '请输入名称', trigger: 'blur' }]
       },
       resultData: null, //  设备搜索结果
-      isFocus: false //  搜索框是否获取焦点
+      isFocus: false, //  搜索框是否获取焦点
+      vsDeviceId: '', //  设备id
+      deviceId: '' //  设备通道id
     }
   },
   methods: {
+    //  搜索设备
     onSearch (value) {
-      findVsDevice({ id: value }).then(res => {
-        if (res.status == 200) {
-          this.resultData = res.data
-        } else {
-          this.$message.error(res.message)
-        }
-      })
+      if (value) {
+        findVsDevice({ id: value }).then(res => {
+          if (res.status == 200) {
+            this.resultData = res.data
+          } else {
+            this.$message.error(res.message)
+          }
+        })
+      } else {
+        this.resultData = null
+        this.isFocus = false
+      }
     },
     //  门店已绑设备
     getStoreEquipment (id) {
       findStoreVsDevice({ code: id }).then(res => {
         if (res.status == 200) {
-          console.log(res)
           res.data.map((item, ind) => {
             item.no = ind + 1
           })
@@ -168,7 +176,7 @@ export default {
           unbindVsDevice({ id: item.id }).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
-              _this.$refs.table.refresh()
+              _this.getStoreEquipment(_this.storeCode)
             } else {
               _this.$message.error(res.message)
             }
@@ -188,7 +196,7 @@ export default {
               _this.$message.success(res.message)
               _this.resultData = null
               _this.isFocus = false
-              _this.$refs.table.refresh()
+              _this.getStoreEquipment(_this.storeCode)
             } else {
               _this.$message.error(res.message)
             }
@@ -198,7 +206,8 @@ export default {
     },
     //  编辑  通道/机位名称
     onEdit (item) {
-      this.form.name = item.name
+      this.form.deviceName = item.name
+      this.deviceId = item.deviceId
       this.visible = true
     },
     //  提交更改的通道信息
@@ -207,21 +216,40 @@ export default {
       _this.$refs.ruleForm.validate(valid => {
         if (valid) {
           const formData = JSON.parse(JSON.stringify(_this.form))
-          formData.tenantId = this.storeId
-          console.log(formData)
-          // saveStoreOrg(formData).then(res => {
-          //   if (res.status == 200) {
-          //     _this.$message.success(res.message)
-          //     _this.$refs.tables.refresh(true)
-          //     _this.visible = false
-          //   } else {
-          //     _this.$message.error(res.message)
-          //   }
-          // })
+          formData.deviceId = this.deviceId
+          vsDeviceRename(formData).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.visible = false
+              _this.getDeviceChannels()
+            } else {
+              _this.$message.error(res.message)
+            }
+          })
         } else {
           return false
         }
       })
+    },
+    //  设备行展开事件
+    eqExpand (expanded, record) {
+      if (expanded) { //  展开行
+        this.vsDeviceId = record.vsDeviceId
+        this.getDeviceChannels()
+      }
+    },
+    //  获取设备通道信息
+    getDeviceChannels () {
+      vsDeviceChannels({ id: this.vsDeviceId }).then(res => {
+        if (res.status == 200) {
+          if (res.data) {
+            res.data.map((item, ind) => {
+              item.no = ind + 1
+            })
+            this.passagewayData = res.data
+          }
+        }
+      })
     }
   },
   watch: {
@@ -234,7 +262,9 @@ export default {
       if (!val) {
         this.$emit('close')
       } else {
-
+        //  重置信息
+        this.resultData = null
+        this.isFocus = false
       }
     },
     storeCode (newValue, oldValue) {
@@ -285,7 +315,7 @@ export default {
     .eq-tit{
       line-height: 40px;
       font-size: 16px;
-      margin: 75px 0 5px;
+      margin: 85px 0 5px;
     }
     .eq-subTit{
       margin: 0 0 10px;

+ 65 - 21
src/views/BasicSettings/StoreManagement.vue

@@ -16,17 +16,27 @@
           </a-col>
           <a-col :span="6">
             <a-form-item class="search-item" label="组织机构">
-              <a-input id="store-orgCode" v-model.trim="queryParam.orgCode" placeholder="请选择组织机构" @pressEnter="$refs.table.refresh(true)" allowClear />
+              <!-- <a-input id="store-orgCode" v-model.trim="queryParam.orgCode" placeholder="请选择组织机构" @pressEnter="$refs.table.refresh(true)" allowClear /> -->
+              <a-tree-select
+                showSearch
+                id="store-orgCode"
+                v-model="queryParam.orgCode"
+                allowClear
+                :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
+                :tree-data="treeData"
+                placeholder="请选择组织机构"
+                treeNodeFilterProp="title">
+              </a-tree-select>
             </a-form-item>
           </a-col>
           <a-col :span="6">
             <a-form-item class="search-item" label="门店类型">
-              <!-- <v-select id="store-type" ref="businessStatus" allowClear placeholder="请选择门店类型" v-model="queryParam.type" code="STORE_BUSINESS_STATUS"></v-select> -->
+              <!-- <v-select id="store-type" ref="businessStatus" allowClear placeholder="请选择门店类型" v-model="queryParam.selfFlag" code="STORE_BUSINESS_STATUS"></v-select> -->
             </a-form-item>
           </a-col>
           <a-col :span="6">
             <a-form-item class="search-item" label="启用状态">
-              <!-- <v-select id="store-status" ref="deviceStatus" allowClear placeholder="请选择启用状态" v-model="queryParam.enableFlag" code="DEVICE_STATUS"></v-select> -->
+              <!-- <v-select id="store-status" ref="deviceStatus" allowClear placeholder="请选择启用状态" v-model="queryParam.isEnable" code="DEVICE_STATUS"></v-select> -->
             </a-form-item>
           </a-col>
           <a-col :span="6">
@@ -40,7 +50,7 @@
     <s-table
       ref="table"
       size="default"
-      rowKey="id"
+      :rowKey="(record) => record.id"
       :columns="columns"
       :data="loadData"
       bordered>
@@ -64,6 +74,7 @@ import StoreModal from './StoreModal.vue'
 import StoreAssociatedEquipmentModal from './StoreAssociatedEquipmentModal.vue'
 // import { getProvince, getCityByPro } from '@/api/lookup'
 import { findStoreList } from '@/api/store.js'
+import { findOrgTree } from '@/api/atorg.js'
 export default {
   name: 'StoreManagement',
   components: { STable, VSelect, StoreModal, StoreAssociatedEquipmentModal },
@@ -72,16 +83,16 @@ export default {
       queryParam: {
         name: '', //  门店名称
         managerMobile: '', //  负责人手机
-        orgCode: '', //  组织机构
-        type: '', //  门店类型
-        enableFlag: '' //  启用状态
+        orgCode: null, //  组织机构
+        selfFlag: '', //  门店类型
+        isEnable: '' //  启用状态
       },
       columns: [
-        { title: '序号', dataIndex: 'no', width: '100', align: 'center' },
+        { title: '序号', dataIndex: 'no', width: '40', align: 'center' },
         { title: '创建时间', dataIndex: 'createDate', 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: 'selfFlag', width: '100', align: 'center' },
         { title: '负责人名称', dataIndex: 'managerName', width: '100', align: 'center' },
         { title: '负责人手机', dataIndex: 'managerMobile', width: '100', align: 'center' },
         { title: '启用状态', dataIndex: 'isEnable', width: '100', align: 'center' },
@@ -89,24 +100,57 @@ export default {
       ],
       // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
-        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++) {
-            const _item = res.data.list[i]
-            _item.no = no + i + 1
+        return findStoreList(Object.assign(parameter, this.queryParam)).then(res => {
+          if (res.status == 200) {
+            const no = (res.data.pageNo - 1) * res.data.pageSize
+            for (let i = 0; i < res.data.list.length; i++) {
+              const _item = res.data.list[i]
+              _item.no = no + i + 1
+            }
+            res.data.count = Number(res.data.count)
+            return res.data
           }
-          return res.data
         })
       },
       openModal: false, //  编辑 门店所属组织  弹框展示状态
       openEquipmentModal: false, //  门店 关联设备  弹框展示状态
       storeId: '', //  门店id
-      storeCode: '' //  门店code
+      storeCode: '', //  门店code
+      treeData: [] //  组织机构
     }
   },
+  mounted () {
+    this.getOrgList()
+  },
   methods: {
+    //  获取组织机构  数据
+    getOrgList () {
+      findOrgTree().then(res => {
+        if (res.status == 200) {
+          this.treeData = this.recursionFun(res.data)
+        } else {
+          this.treeData = []
+        }
+      })
+    },
+    //  递归函数
+    recursionFun (data) {
+      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
+    },
     //  编辑
     edit (item) {
       this.storeId = String(item.id)
@@ -131,9 +175,9 @@ export default {
       this.queryParam = {
         name: '', //  门店名称
         managerMobile: '', //  负责人手机
-        orgCode: '', //  组织机构
-        type: '', //  门店类型
-        enableFlag: '' //  启用状态
+        orgCode: null, //  组织机构
+        selfFlag: '', //  门店类型
+        isEnable: '' //  启用状态
       }
       this.addrCityList = []
       this.$refs.table.refresh(true)

+ 1 - 1
src/views/BasicSettings/StoreModal.vue

@@ -107,7 +107,7 @@ export default {
       rules: { //  表单校验规则
         orgCode: [{ required: true, message: '请选择所属组织归属', trigger: 'change' }]
       },
-      treeData: [],
+      treeData: [], //  组织机构
       parentCodePaths: '', //  机构编码父路径
       storeInfo: null //  门店详情
     }