Browse Source

公共组件:查询用户

chris 3 năm trước cách đây
mục cha
commit
dc4c5e7675

+ 104 - 0
src/views/modules/common/user-component.vue

@@ -0,0 +1,104 @@
+<template>
+    <div>
+      <el-select
+        v-model="value"
+        ref="select"
+        placeholder="请输入姓名"
+        filterable
+        @change = "onChange"
+        v-el-select-loadmore="loadMore">
+        <el-option
+          v-for="item in options"
+          :key="item.value"
+          :label="item.label"
+          :value="item.value">
+        </el-option>
+      </el-select>
+    </div>
+</template>
+
+<script>
+  export default {
+    name: 'user-component',
+    props: {
+      userId: {
+        type: String,
+        default: ''
+      }
+    },
+    model: {
+      prop: 'userId',
+      event: 'userSelected'
+    },
+    directives: {
+      'el-select-loadmore': {
+        bind (el, binding) {
+          // 获取element-ui定义好的scroll盒子
+          const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
+          SELECTWRAP_DOM.addEventListener('scroll', function () {
+            const condition = this.scrollHeight - this.scrollTop <= this.clientHeight
+            if (condition) {
+              binding.value()
+            }
+          })
+        }
+      }
+    },
+    data () {
+      return {
+        value: '',
+        current: 1,
+        size: 5,
+        name: '',
+        options: [],
+        loading: false,
+        noMore: false
+      }
+    },
+    mounted () {
+      this.init()
+    },
+    methods: {
+      async init () {
+        this.getList()
+      },
+      getList () {
+        this.$http({
+          url: this.$http.adornUrl(`/user-service/user/list`),
+          method: 'get',
+          params: this.$http.adornParams({
+            'current': this.current,
+            'size': this.size,
+            'name': this.name
+          })
+        }).then(({data}) => {
+          if (data && data.code === '200') {
+            if (this.current > data.data.pages) {
+              return
+            }
+            data.data.records.forEach(item => {
+              this.options.push({
+                label: item.name + ' (' + item.orgName + ')',
+                value: item.userId
+              })
+            })
+          } else {
+            this.options = []
+          }
+        })
+      },
+      loadMore () {
+        this.current ++
+        this.getList()
+      },
+      onChange (item) {
+        console.log('item = ' + item)
+        this.$emit('userSelected', item)
+      }
+    }
+  }
+</script>
+
+<style scoped>
+
+</style>

+ 66 - 3
src/views/modules/warehouse/stock-order.vue

@@ -1,12 +1,75 @@
 <template>
-  <div>
-    出入库管理
+  <div class="stock-order">
+    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
+      <el-form-item>
+        <user-component v-model="dataForm.userId"/>
+      </el-form-item>
+<!--      <el-form-item>-->
+<!--        <el-input v-model="dataForm.userName" placeholder="用户名" clearable></el-input>-->
+<!--      </el-form-item>-->
+      <el-form-item>
+        <el-button @click="getDataList()">查询</el-button>
+<!--        <el-button v-if="isAuth('sys:user:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>-->
+<!--        <el-button v-if="isAuth('sys:user:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>-->
+      </el-form-item>
+    </el-form>
   </div>
 </template>
 
 <script>
+  import UserComponent from '../common/user-component'
   export default {
-    name: 'stock-order'
+    name: 'stock-order',
+    components: {UserComponent},
+    data () {
+      return {
+        dataForm: {
+          userId: ''
+        },
+        dataList: [],
+        pageIndex: 1,
+        pageSize: 10,
+        totalPage: 0,
+        dataListLoading: false,
+        dataListSelections: []
+      }
+    },
+    methods: {
+      // 获取数据列表
+      getDataList () {
+        console.log('参数:' + this.dataForm.userId)
+        // this.dataListLoading = true
+        // this.$http({
+        //   url: this.$http.adornUrl('/user-service/user/list'),
+        //   method: 'get',
+        //   params: this.$http.adornParams({
+        //     'current': this.pageIndex,
+        //     'size': this.pageSize,
+        //     'userId': this.dataForm.userId
+        //   })
+        // }).then(({data}) => {
+        //   if (data && data.code === '200') {
+        //     this.dataList = data.data.records
+        //     this.totalPage = Number(data.data.total)
+        //   } else {
+        //     this.dataList = []
+        //     this.totalPage = 0
+        //   }
+        //   this.dataListLoading = false
+        // })
+      },
+      // 每页数
+      sizeChangeHandle (val) {
+        this.pageSize = val
+        this.pageIndex = 1
+        this.getDataList()
+      },
+      // 当前页
+      currentChangeHandle (val) {
+        this.pageIndex = val
+        this.getDataList()
+      }
+    }
   }
 </script>