Browse Source

门店管理

chenrui 4 years ago
parent
commit
a15d84f061

+ 34 - 0
src/api/storeVsDevice.js

@@ -0,0 +1,34 @@
+import { axios } from '@/utils/request'
+
+// 门店绑定设备信息
+export const bindVsDevice = params => {
+  return axios({
+    url: '/storeVsDevice/bindVsDevice',
+    data: params,
+    method: 'post'
+  })
+}
+// 查询门店设备信息
+export const findStoreVsDevice = params => {
+  return axios({
+    url: `/storeVsDevice/findStoreVsDevice/${params.id}`,
+    data: {},
+    method: 'get'
+  })
+}
+// 根据设备编号查询设备信息
+export const findVsDevice = params => {
+  return axios({
+    url: `/storeVsDevice/findVsDevice/${params.id}`,
+    data: {},
+    method: 'get'
+  })
+}
+// 门店解绑设备信息
+export const unbindVsDevice = params => {
+  return axios({
+    url: '/storeVsDevice/unbindVsDevice',
+    data: params,
+    method: 'post'
+  })
+}

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

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

+ 277 - 0
src/views/BasicSettings/StoreAssociatedEquipmentModal.vue

@@ -0,0 +1,277 @@
+<template>
+  <a-modal
+    class="StoreAssociatedEquipmentModal-wrap"
+    title="关联摄像设备"
+    :width="1000"
+    :footer="null"
+    :destroyOnClose="true"
+    @cancel="isShow = false"
+    v-model="isShow">
+    <div class="search-con" @blur="isFocus=false">
+      <a-input-search
+        class="search-s"
+        allow-clear
+        placeholder="请通过设备ID搜索"
+        enter-button="查询"
+        size="large"
+        @focus="isFocus=true"
+        @search="onSearch"
+      />
+      <a-card class="search-sub" :bordered="false" v-show="resultData.length != 0 && isFocus">
+        <div class="search-sub-item" v-for="(item, index) in resultData" :key="index">
+          <p>{{ item.des }}-{{ item.isBind ? '已绑定' : '未绑定' }}</p>
+          <a-button v-if="!item.isBind" type="primary" ghost size="small" @click="onBundling(item)">立即绑定</a-button>
+        </div>
+      </a-card>
+    </div>
+    <div class="eq-tit">已绑设备:</div>
+    <a-table
+      class="table"
+      ref="table"
+      bordered
+      size="small"
+      :columns="columns"
+      :data-source="equipmentData"
+      :pagination="false">
+      <div slot="expandedRowRender" slot-scope="record" style="margin: 30px 30px;">
+        <a-table
+          ref="tables"
+          bordered
+          size="small"
+          :columns="passagewayColumns"
+          :data-source="record.passageway"
+          :pagination="false">
+          <template slot="action" slot-scope="record">
+            <a-button type="link" @click="onEdit(record)">编辑</a-button>
+          </template>
+        </a-table>
+      </div>
+      <template slot="action" slot-scope="record">
+        <a-button type="primary" ghost size="small" @click="onUnbundling(record)">解绑</a-button>
+      </template>
+    </a-table>
+    <!-- 编辑  通道/机位名称 -->
+    <a-modal
+      class="passagewayModal"
+      title="编辑"
+      :visible="visible"
+      :footer="null"
+      :closable="true"
+      @cancel="visible=false"
+      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" :maxLength="30" placeholder="请输入名称,30个字以内" />
+        </a-form-model-item>
+        <a-form-model-item class="btn-cont">
+          <a-button type="primary" @click="onSubmit">保存</a-button>
+          <a-button class="cancel" @click="visible=false">取消</a-button>
+        </a-form-model-item>
+      </a-form-model>
+    </a-modal>
+  </a-modal>
+</template>
+
+<script>
+import { findStoreVsDevice, unbindVsDevice, findVsDevice, bindVsDevice } from '@/api/storeVsDevice.js'
+export default {
+  name: 'StoreAssociatedEquipmentModal',
+  props: {
+    openModal: {
+      //  弹框是否展示
+      type: Boolean,
+      default: false
+    },
+    storeId: {
+      //  门店id
+      type: String,
+      default: ''
+    }
+  },
+  data () {
+    return {
+      isShow: this.openModal, //  弹框是否展示
+      columns: [
+        { title: '序号', dataIndex: 'no', width: '100', align: 'center' },
+        { title: '设备名称', dataIndex: 'name', width: '100', align: 'center' },
+        { title: '设备ID', dataIndex: 'id', width: '100', align: 'center' },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: '265', align: 'center' }
+      ],
+      equipmentData: [], //  已绑设备
+      passagewayColumns: [
+        { title: '序号', dataIndex: 'no', width: '100', align: 'center' },
+        { title: '设备名称', dataIndex: 'name', width: '100', align: 'center' },
+        { title: '设备ID', dataIndex: 'id', width: '100', align: 'center' },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: '265', align: 'center' }
+      ],
+      visible: false, //  编辑  通道/机位名称
+      form: {
+        name: '' //  名称
+      },
+      rules: { //  表单校验规则
+        name: [{ required: true, message: '请输入名称', trigger: 'blur' }]
+      },
+      resultData: [], //  设备搜索结果
+      isFocus: false //  搜索框是否获取焦点
+    }
+  },
+  methods: {
+    onSearch (value) {
+      findVsDevice({ id: value }).then(res => {
+        if (res.status == 200) {
+          this.resultData = res.data
+        } else {
+          this.$message.error(res.message)
+        }
+      })
+    },
+    //  门店已绑设备
+    getStoreEquipment (id) {
+      findStoreVsDevice({ id: id }).then(res => {
+        if (res.status == 200) {
+          res.data.map((item, ind) => {
+            item.no = ind + 1
+          })
+          this.equipmentData = res.data
+        }
+      })
+    },
+    //  解绑
+    onUnbundling (item) {
+      const _this = this
+      _this.$confirm({
+        title: '提示',
+        content: '确定解绑该设备吗?',
+        onOk () {
+          unbindVsDevice({ tenantId: _this.storeId, vsDeviceId: item.id }).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$refs.table.refresh()
+            } else {
+              _this.$message.error(res.message)
+            }
+          })
+        }
+      })
+    },
+    //  绑定
+    onBundling (item) {
+      const _this = this
+      _this.$confirm({
+        title: '提示',
+        content: '确定要绑定该设备吗?',
+        onOk () {
+          bindVsDevice({ tenantId: _this.storeId, vsDeviceId: item.id }).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$refs.table.refresh()
+            } else {
+              _this.$message.error(res.message)
+            }
+          })
+        }
+      })
+    },
+    //  编辑  通道/机位名称
+    onEdit (item) {
+      this.form.name = item.name
+      this.visible = true
+    },
+    //  提交更改的通道信息
+    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)
+          // 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)
+          //   }
+          // })
+        } else {
+          return false
+        }
+      })
+    }
+  },
+  watch: {
+    //  父页面传过来的弹框状态
+    openModal (newValue, oldValue) {
+      this.isShow = newValue
+    },
+    //  重定义的弹框状态
+    isShow (val) {
+      if (!val) {
+        this.$emit('close')
+      } else {
+
+      }
+    },
+    storeId (newValue, oldValue) {
+      if (newValue && this.isShow) {
+        this.getStoreEquipment(newValue)
+      }
+    }
+  }
+}
+</script>
+
+<style lang="less">
+  .StoreAssociatedEquipmentModal-wrap{
+    .search-con{
+      position: relative;
+      .search-s{
+        .ant-input-group-addon{
+          padding: 0;
+          border: none;
+        }
+      }
+      .search-sub{
+        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
+        position: absolute;
+        left: 0;
+        top: 45px;
+        width: 100%;
+        z-index: 1;
+        border-radius: 6px;
+        .ant-card-body{
+          padding: 15px 24px;
+        }
+        .search-sub-item{
+          display: flex;
+          justify-content: space-between;
+          align-items: center;
+          padding: 8px 0;
+          border-bottom: 1px dashed #f8f8f8;
+          p{
+            margin: 0;
+          }
+          &:last-child{
+            border-bottom: none;
+          }
+        }
+      }
+    }
+    .eq-tit{
+      line-height: 40px;
+      font-size: 16px;
+      margin: 75px 0 5px;
+    }
+    .table{
+      padding-bottom: 50px;
+    }
+  }
+  .btn-cont{
+    text-align: center;
+    .cancel{
+      margin-left: 40px;
+    }
+  }
+</style>

+ 17 - 27
src/views/BasicSettings/StoreManagement.vue

@@ -47,26 +47,26 @@
       <!-- 操作 -->
       <!-- 操作 -->
       <template slot="action" slot-scope="text, record">
       <template slot="action" slot-scope="text, record">
         <a-icon type="edit" title="编辑" @click="edit(record)" :style="{ fontSize: '20px', color: '#1890FF', padding: '0 10px' }" />
         <a-icon type="edit" title="编辑" @click="edit(record)" :style="{ fontSize: '20px', color: '#1890FF', padding: '0 10px' }" />
-        <a-icon type="link" title="设置" @click="modalHandle('details', record)" :style="{ fontSize: '20px', color: '#e29e14', padding: '0 10px' }" />
+        <a-icon type="link" title="设置" @click="setEquipment(record)" :style="{ fontSize: '20px', color: '#e29e14', padding: '0 10px' }" />
       </template>
       </template>
     </s-table>
     </s-table>
 
 
-    <!-- 新增/编辑 洗车机 -->
-    <store-modal :openModal="openModal" :storeId="storeId" @success="carWashSubmit" @close="closeModal" />
-    <!-- 查看详情 洗车机 -->
-    <!-- <details-car-wash-modal :openModal="openEquipmentModal" :storeId="storeId" @close="closeDetailsModal" /> -->
+    <!-- 编辑 门店所属组织 -->
+    <store-modal :openModal="openModal" :storeId="storeId" @success="storeSubmit" @close="closeModal" />
+    <!-- 门店 关联设备 -->
+    <store-associated-equipment-modal :openModal="openEquipmentModal" :storeId="storeId" @close="closeDetailsModal" />
   </a-card>
   </a-card>
 </template>
 </template>
 
 
 <script>
 <script>
 import { STable, VSelect } from '@/components'
 import { STable, VSelect } from '@/components'
 import StoreModal from './StoreModal.vue'
 import StoreModal from './StoreModal.vue'
-// import DetailsCarWashModal from './DetailsCarWashModal.vue'
+import StoreAssociatedEquipmentModal from './StoreAssociatedEquipmentModal.vue'
 // import { getProvince, getCityByPro } from '@/api/lookup'
 // import { getProvince, getCityByPro } from '@/api/lookup'
 import { findStoreList } from '@/api/store.js'
 import { findStoreList } from '@/api/store.js'
 export default {
 export default {
   name: 'CarWashManagement',
   name: 'CarWashManagement',
-  components: { STable, VSelect, StoreModal },
+  components: { STable, VSelect, StoreModal, StoreAssociatedEquipmentModal },
   data () {
   data () {
     return {
     return {
       queryParam: {
       queryParam: {
@@ -99,27 +99,11 @@ export default {
           return res.data
           return res.data
         })
         })
       },
       },
-      openModal: false, //  新增/编辑 洗车机  弹框展示状态
-      pageType: '', //  新增/编辑 洗车机  页面类型
-      openEquipmentModal: false, //  查看详情 洗车机  弹框展示状态
-      addrProvinceList: [], //  省列表数据
-      addrCityList: [], //  市列表数据
-      isQrCodeModal: false, //  查看小程序码   弹框展示状态
-      qrCode: '', //  小程序码
-      storeId: '' //  网点id
+      openModal: false, //  编辑 门店所属组织  弹框展示状态
+      openEquipmentModal: false, //  门店 关联设备  弹框展示状态
+      storeId: '' //  门店id
     }
     }
   },
   },
-  mounted () {
-    const arr = [
-      { a: 1, b: 3 },
-      { a: 11, b: 331 },
-      { a: 111, b: 333 },
-      { a: 1111, b: 33 }
-    ]
-    const arrs = { a: { b: 1, c: 3 } }
-    arr.push({ a: arrs['a'].b, b: arrs['a'].c })
-    console.log(arr)
-  },
   methods: {
   methods: {
     //  编辑
     //  编辑
     edit (item) {
     edit (item) {
@@ -128,10 +112,16 @@ export default {
       this.openEquipmentModal = false
       this.openEquipmentModal = false
     },
     },
     // 新增编辑  提交成功
     // 新增编辑  提交成功
-    carWashSubmit () {
+    storeSubmit () {
       this.$refs.table.refresh(true)
       this.$refs.table.refresh(true)
       this.openModal = false
       this.openModal = false
     },
     },
+    //  设置
+    setEquipment (item) {
+      this.storeId = String(item.id)
+      this.openEquipmentModal = true
+      this.openModal = false
+    },
     //  重置
     //  重置
     reset () {
     reset () {
       this.queryParam = {
       this.queryParam = {

+ 10 - 11
src/views/BasicSettings/StoreModal.vue

@@ -153,14 +153,14 @@ export default {
           const formData = JSON.parse(JSON.stringify(_this.form))
           const formData = JSON.parse(JSON.stringify(_this.form))
           formData.tenantId = this.storeId
           formData.tenantId = this.storeId
           console.log(formData)
           console.log(formData)
-          // saveStoreOrg(formData).then(res => {
-          //   if (res.status == 200) {
-          //     _this.$message.success(res.message)
-          //     _this.$emit('success')
-          //   } else {
-          //     _this.$message.error(res.message)
-          //   }
-          // })
+          saveStoreOrg(formData).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$emit('success')
+            } else {
+              _this.$message.error(res.message)
+            }
+          })
         } else {
         } else {
           return false
           return false
         }
         }
@@ -177,9 +177,8 @@ export default {
       if (!val) {
       if (!val) {
         this.$emit('close')
         this.$emit('close')
       } else {
       } else {
-        // this.resetForm() //  重置表单数据
-        // this.getProvinceList() //  获取省下拉
-        // this.getItemQuery() //  服务类型  列表
+        //  重置表单数据
+        this.form.orgCode = null
       }
       }
     },
     },
     storeId (newValue, oldValue) {
     storeId (newValue, oldValue) {