春风项目四线(合箱线、总装线)
wujian
2024-08-03 131e8c0adbd4f56e1f7e7f877ff1b03e1683314f
提交 | 用户 | 时间
fd2207 1 <template>
2   <el-dialog title="物料产品选择"
3              v-if="showFlag"
4              :visible.sync="showFlag"
5              :modal= false
6              width="80%"
7              center
8   >
9     <el-row :gutter="20">
10       <!--物料数据-->
11       <el-col :span="24" :xs="24">
12         <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
1e3074 13           <el-form-item label="物料编码" prop="materialCode">
fd2207 14             <el-input
1e3074 15               v-model="queryParams.materialCode"
fd2207 16               placeholder="请输入物料编码"
17               clearable
18               style="width: 240px"
19               @keyup.enter.native="handleQuery"
20             />
21           </el-form-item>
1e3074 22           <el-form-item label="物料名称" prop="materialName">
fd2207 23             <el-input
1e3074 24               v-model="queryParams.materialName"
fd2207 25               placeholder="请输入物料名称"
26               clearable
27               style="width: 240px"
28               @keyup.enter.native="handleQuery"
29             />
30           </el-form-item>
31           <el-form-item style="float: right">
32             <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
33             <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
34           </el-form-item>
35         </el-form>
36         <el-table border v-loading="loading" :data="itemList" @current-change="handleCurrent" @row-dblclick="handleRowDbClick">
37           <el-table-column width="50" align="center" >
38             <template v-slot="scope">
39               <el-radio v-model="selectedItemId" :label="scope.row.id" @change="handleRowChange(scope.row)">{{""}}</el-radio>
40             </template>
41           </el-table-column>
42           <el-table-column label="物料编号" align="center" prop="materialCode">
43           </el-table-column>
44           <el-table-column label="物料名称" align="center" prop="materialName">
45           </el-table-column>
46           <el-table-column label="类型" align="center" prop="typeL">
47             <template slot-scope="scope">
48               <dict-tag :options="dict.type.material_type" :value="scope.row.typeL"/>
49             </template>
50           </el-table-column>
51           <el-table-column label="单位" align="center" prop="unit">
52             <template slot-scope="scope">
53               <dict-tag :options="dict.type.unit" :value="scope.row.unit"/>
54             </template>
55           </el-table-column>
56           <el-table-column label="创建时间" align="center" prop="createTime">
57           </el-table-column>
58           <el-table-column label="状态" align="center" prop="status">
59             <template slot-scope="scope">
60               <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
61             </template>
62           </el-table-column>
63           <el-table-column label="厂商" align="center" prop="supplier">
64           </el-table-column>
65         </el-table>
66
67         <pagination
68           v-show="total>0"
69           :total="total"
70           :page.sync="queryParams.pageNum"
71           :limit.sync="queryParams.pageSize"
72           @pagination="getList"
73         />
74       </el-col>
75     </el-row>
76     <div slot="footer" class="dialog-footer">
77       <el-button type="primary" @click="confirmSelect">确 定</el-button>
78       <el-button @click="showFlag=false">取 消</el-button>
79     </div>
80   </el-dialog>
81 </template>
82
83 <script>
84 import { listMaterial} from "@/api/main/bs/material/material";
85
86 export default {
87   name: "MdItemSingle",
88   dicts: ['sys_yes_no','mes_item_product','material_type','unit','sys_normal_disable'],
89   data() {
90     return {
91       showFlag:false,
92       // 选中数组
93       selectedItemId: undefined,
94       selectedRows: undefined,
95       // 非单个禁用
96       single: true,
97       // 非多个禁用
98       multiple: true,
99       // 显示搜索条件
100       showSearch: true,
101       // 总条数
102       total: 0,
103       // 物料产品表格数据
104       itemList: null,
105       // 部门树选项
106       itemTypeOptions: undefined,
107       // 部门名称
108       itemTypeName: undefined,
109       defaultProps: {
110         children: "children",
111         label: "label"
112       },
113       // 查询参数
114       queryParams: {
115         pageNum: 1,
116         pageSize: 10,
1e3074 117         materialCode: undefined,
W 118         materialName: undefined,
131e8c 119         itemTypeId: null,
W 120         typeL: null,
fd2207 121       },
122       // 列信息
123       columns: [
124         { key: 0, label: `物料/产品编码`, visible: true },
125         { key: 1, label: `物料/产品名称`, visible: true },
126         { key: 2, label: `规格型号`, visible: true },
127         { key: 3, label: `单位`, visible: true },
128         { key: 4, label: `物料/产品`, visible: true },
129         { key: 5, label: `物料分类`, visible: true },
130         { key: 6, label: `创建时间`, visible: true }
131       ]
132     };
133   },
134   watch: {
135     // 根据名称筛选分类树
136     itemTypeName(val) {
137       this.$refs.tree.filter(val);
138     }
139   },
140   created() {
141     this.getList();
142   },
143   methods: {
144     /** 查询物料编码列表 */
145     getList() {
146       this.loading = true;
147       listMaterial(this.queryParams).then(response => {
148           this.itemList = response.rows;
149           this.total = response.total;
150           this.loading = false;
151         }
152       );
153     },
154     // 筛选节点
155     filterNode(value, data) {
156       if (!value) return true;
157       return data.label.indexOf(value) !== -1;
158     },
159     // 节点单击事件
160     handleNodeClick(data) {
161       this.queryParams.itemTypeId = data.id;
162       this.handleQuery();
163     },
164     /** 搜索按钮操作 */
165     handleQuery() {
166       this.queryParams.pageNum = 1;
167       this.getList();
168     },
169     /** 重置按钮操作 */
170     resetQuery() {
171       this.resetForm("queryForm");
172       this.handleQuery();
173     },
174     handleCurrent(row){
175       if(row){
176         this.selectedRows = row;
177       }
178     },
179     handleRowDbClick(row){
180       if(row){
181         this.selectedRows = row;
182         this.$emit('onSelected',this.selectedRows);
183         this.showFlag = false;
184       }
185     },
186     // 单选选中数据
187     handleRowChange(row) {
188       if(row){
189         this.selectedRows = row;
190       }
191     },
192     //确定选中
193     confirmSelect(){
194       if(this.selectedItemId ==null || this.selectedItemId==0){
195         this.$notify({
196           title:'提示',
197           type:'warning',
198           message: '请至少选择一条数据!'
199         });
200         return;
201       }
202       console.log(this.selectedRows)
203
204       this.$emit('onSelected',this.selectedRows);
205       this.showFlag = false;
206     }
207   }
208 };
209 </script>