hdy
2 天以前 1c50cb5546715fa21496fbdf2bdacb7ae8836b8a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<template>
  <el-dialog :title="title" :visible.sync="visible" width="1000px" @close="handleClose">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="物料编号" prop="materialCode">
        <el-input
          v-model="queryParams.materialCode"
          placeholder="请输入物料编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料名称" prop="materialName">
        <el-input
          v-model="queryParams.materialName"
          placeholder="请输入物料名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item style="float: right">
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table border ref="multipleTable" v-loading="loading" :data="materialInfoList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column :show-overflow-tooltip="true" label="物料编号" align="center" prop="materialCode" />
      <el-table-column :show-overflow-tooltip="true" label="物料名称" align="center" prop="materialName" />
      <el-table-column :show-overflow-tooltip="true" label="视图" align="center" prop="materialView" />
      <el-table-column label="种类" align="center" prop="typeZ">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.type_z" :value="scope.row.typeZ"/>
        </template>
      </el-table-column>
      <el-table-column label="类型" align="center" prop="typeL">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.type_l" :value="scope.row.typeL"/>
        </template>
      </el-table-column>
      <el-table-column label="单位" align="center" prop="unit">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.unit" :value="scope.row.unit"/>
        </template>
      </el-table-column>
      <el-table-column :show-overflow-tooltip="true" label="版本" align="center" prop="version" />
      <el-table-column label="状态" align="center" prop="status">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
        </template>
      </el-table-column>
      <el-table-column :show-overflow-tooltip="true" label="厂商" align="center" prop="supplier" />
      <el-table-column :show-overflow-tooltip="true" label="备注" align="center" prop="remark" />
      <el-table-column :show-overflow-tooltip="true" label="数据来源" align="center" prop="dataSource" />
      <el-table-column :show-overflow-tooltip="true" label="创建用户" align="center" prop="createBy" />
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
      </el-table-column>
      <el-table-column :show-overflow-tooltip="true" label="更改用户" align="center" prop="updateBy" />
      <el-table-column label="更改时间" align="center" prop="updateTime" width="180">
      </el-table-column>
    </el-table>
 
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <div slot="footer" class="dialog-footer">
      <el-button @click="handleClose">取 消</el-button>
      <el-button type="primary" @click="confirmSelection">确 定</el-button>
    </div>
  </el-dialog>
</template>
 
<script>
import {listMaterialInfo} from "@/api/main/bs/materialInfo";
 
export default {
  name: "ProductSelector",
  dicts: ['sys_normal_disable', 'type_l', 'unit', 'type_z'],
  props: {
    visible: Boolean,
    title: {
      type: String,
      default: "物料信息"
    },
    gridData: Array
  },
  data() {
    return {
      // 总条数
      total: 0,
      // 物料信息表格数据
      materialInfoList: [],
      // 遮罩层
      loading: true,
      showSearch: true,
      multipleSelection: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        materialCode: null,
        materialName: null,
        materialView: null,
        typeZ: null,
        typeL: null,
        unit: null,
        status: null,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询物料信息列表 */
    getList() {
      this.loading = true;
      listMaterialInfo(this.queryParams).then(response => {
        this.materialInfoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    handleClose() {
      this.$emit('update:visible', false);
    },
    handleSelectionChange(selection) {
      if (selection.length > 1) {
        this.$refs.multipleTable.clearSelection();
        this.$refs.multipleTable.toggleRowSelection(selection[selection.length - 1], true);
        this.multipleSelection = [selection[selection.length - 1]];
      } else {
        this.multipleSelection = selection;
      }
    },
    confirmSelection() {
      if (this.multipleSelection.length > 0) {
        this.$emit('select-product', this.multipleSelection[0]);
        this.handleClose();
        this.$refs.multipleTable.clearSelection();
      } else {
        this.$message({
          message: '警告哦,未选择任何行',
          type: 'warning'
        });
      }
    }
  }
};
</script>