|
|
@@ -0,0 +1,382 @@
|
|
|
+<template>
|
|
|
+ <el-dialog
|
|
|
+ title="选择产品"
|
|
|
+ :visible.sync="visible"
|
|
|
+ v-if="visible"
|
|
|
+ :before-close="handleClose"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ top="5vh"
|
|
|
+ :close-on-press-escape="false"
|
|
|
+ append-to-body
|
|
|
+ width="70%"
|
|
|
+ >
|
|
|
+ <el-card shadow="never">
|
|
|
+ <searchProduct @search="reload"></searchProduct>
|
|
|
+ <ele-split-layout
|
|
|
+ width="244px"
|
|
|
+ allow-collapse
|
|
|
+ :right-style="{ overflow: 'hidden' }"
|
|
|
+ >
|
|
|
+ <div class="ele-border-lighter split-layout-right-content">
|
|
|
+ <productTree
|
|
|
+ @handleNodeClick="handleNodeClick"
|
|
|
+ :isFirstRefreshTable="isFirstRefreshTable"
|
|
|
+ ref="treeList"
|
|
|
+ :ids="ids"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <!-- 表格 -->
|
|
|
+ <template v-slot:content>
|
|
|
+ <ele-pro-table
|
|
|
+ ref="table"
|
|
|
+ :columns="columns"
|
|
|
+ :datasource="datasource"
|
|
|
+ row-key="id"
|
|
|
+ height="calc(100vh - 480px)"
|
|
|
+ class="dict-table"
|
|
|
+ @cell-click="cellClick"
|
|
|
+ :selection.sync="selection"
|
|
|
+ @done="tableDone"
|
|
|
+ :initLoad="!isFirstRefreshTable"
|
|
|
+ >
|
|
|
+ <!-- 表头工具栏 -->
|
|
|
+ <template v-slot:action="{ row }">
|
|
|
+ <el-radio class="radio" v-model="radio" :label="row.code"
|
|
|
+ ><i></i
|
|
|
+ ></el-radio>
|
|
|
+ </template>
|
|
|
+ </ele-pro-table>
|
|
|
+ </template>
|
|
|
+ </ele-split-layout>
|
|
|
+ </el-card>
|
|
|
+
|
|
|
+ <div slot="footer">
|
|
|
+ <el-button type="primary" size="small" @click="selected">选择</el-button>
|
|
|
+ <el-button size="small" @click="handleClose">关闭</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ import { getList } from '@/api/classifyManage/itemInformation';
|
|
|
+ import searchProduct from './searchProduct.vue';
|
|
|
+ import productTree from './productTree.vue';
|
|
|
+ import { getByCode } from '@/api/system/dictionary-data';
|
|
|
+ import { lbjtList } from '@/enum/dict.js';
|
|
|
+
|
|
|
+ export default {
|
|
|
+ components: {
|
|
|
+ productTree,
|
|
|
+ searchProduct,
|
|
|
+ },
|
|
|
+ props: {
|
|
|
+ /*是否需要获取仓库产品数量*/
|
|
|
+ isGetInventoryTotal: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ },
|
|
|
+ /*已选择的产品*/
|
|
|
+ data: {
|
|
|
+ type: Array,
|
|
|
+ default: () => []
|
|
|
+ },
|
|
|
+ /*是否需要cBom*/
|
|
|
+ isShowCBom: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ },
|
|
|
+ typeIds:{
|
|
|
+ type: Array,
|
|
|
+ default: () => []
|
|
|
+ },
|
|
|
+ isFirstRefreshTable: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ },
|
|
|
+ ids:{
|
|
|
+ type: Array,
|
|
|
+ default: () => []
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ visible: false,
|
|
|
+ currentIndex: null,
|
|
|
+ radio: null,
|
|
|
+ dictList: {},
|
|
|
+ selection: [],
|
|
|
+ ids:[]
|
|
|
+ };
|
|
|
+ },
|
|
|
+ watch: {},
|
|
|
+ computed: {
|
|
|
+ columns() {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ action: 'action',
|
|
|
+ slot: 'action',
|
|
|
+ align: 'center',
|
|
|
+ label: '选择',
|
|
|
+ reserveSelection: true,
|
|
|
+ show: this.currentIndex != -1
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '选择',
|
|
|
+ show: this.currentIndex == -1,
|
|
|
+ width: 45,
|
|
|
+ type: 'selection',
|
|
|
+ columnKey: 'selection',
|
|
|
+ align: 'center',
|
|
|
+ reserveSelection: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ columnKey: 'index',
|
|
|
+ type: 'index',
|
|
|
+ width: 50,
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ label: '序号'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'code',
|
|
|
+ label: '编码',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 110
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'name',
|
|
|
+ label: '名称',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 110
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'imgCode',
|
|
|
+ align: 'center',
|
|
|
+ label: '图号/件号',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 110
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'componentAttribute',
|
|
|
+ align: 'center',
|
|
|
+ label: '属性类型',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ formatter: (row, column) => {
|
|
|
+ if(row.produceType){
|
|
|
+ return row.produceType.map(item=>{
|
|
|
+ return lbjtList[item]
|
|
|
+ }).toString()
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ minWidth: 110
|
|
|
+ },
|
|
|
+ // {
|
|
|
+ // prop: 'extField.approvalNumber',
|
|
|
+ // align: 'center',
|
|
|
+ // label: '批准文号',
|
|
|
+ // showOverflowTooltip: true,
|
|
|
+ // minWidth: 110
|
|
|
+ // },
|
|
|
+ {
|
|
|
+ prop: 'extField.packingSpecification',
|
|
|
+ align: 'center',
|
|
|
+ label: '包装规格',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ minWidth: 110
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'brandNum',
|
|
|
+ align: 'center',
|
|
|
+ label: '牌号',
|
|
|
+ showOverflowTooltip: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'modelType',
|
|
|
+ label: '型号',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'specification',
|
|
|
+ label: '规格',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'measuringUnit',
|
|
|
+ label: '计量单位',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ align: 'center',
|
|
|
+ minWidth: 90
|
|
|
+ },
|
|
|
+
|
|
|
+ {
|
|
|
+ prop: 'weightUnit',
|
|
|
+ label: '重量单位',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ align: 'center',
|
|
|
+ minWidth: 90
|
|
|
+ },
|
|
|
+
|
|
|
+ {
|
|
|
+ prop: 'roughWeight',
|
|
|
+ label: '毛重',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ align: 'center',
|
|
|
+ minWidth: 90
|
|
|
+ },
|
|
|
+
|
|
|
+ {
|
|
|
+ prop: 'netWeight',
|
|
|
+ label: '净重',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ align: 'center',
|
|
|
+ minWidth: 90
|
|
|
+ },
|
|
|
+
|
|
|
+ {
|
|
|
+ prop: 'packingUnit',
|
|
|
+ align: 'center',
|
|
|
+ label: '包装单位',
|
|
|
+ showOverflowTooltip: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'categoryLevelPath',
|
|
|
+ label: '分类',
|
|
|
+ align: 'center',
|
|
|
+ showOverflowTooltip: true
|
|
|
+ },
|
|
|
+
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getDictV(code, val) {
|
|
|
+ if (!this.dictList[code]) return '';
|
|
|
+ return this.dictList[code].find((item) => item.value == val)?.label;
|
|
|
+ },
|
|
|
+ async getDictList(code) {
|
|
|
+ let { data: res } = await getByCode(code);
|
|
|
+ this.dictList[code] = res.map((item) => {
|
|
|
+ let values = Object.keys(item);
|
|
|
+ return {
|
|
|
+ value: values[0],
|
|
|
+ label: item[values[0]]
|
|
|
+ };
|
|
|
+ });
|
|
|
+ },
|
|
|
+ open(currentIndex) {
|
|
|
+ this.currentIndex = currentIndex;
|
|
|
+ this.visible = true;
|
|
|
+ this.getDictList('productionType');
|
|
|
+ },
|
|
|
+ /* 表格数据源 */
|
|
|
+ datasource({ page, limit, where, order }) {
|
|
|
+ return getList({
|
|
|
+ pageNum: page,
|
|
|
+ size: limit,
|
|
|
+ ...where
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ /* 刷新表格 */
|
|
|
+ reload(where) {
|
|
|
+ where.categoryLevelId = this.curNodeData?.id;
|
|
|
+
|
|
|
+ this.$refs.table.reload({ pageNum: 1, where: where });
|
|
|
+ },
|
|
|
+
|
|
|
+ handleNodeClick(data, node) {
|
|
|
+ this.curNodeData = data;
|
|
|
+ this.$nextTick(()=>{
|
|
|
+ this.reload({ categoryLevelId: data.id });
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ // 单击获取id
|
|
|
+ cellClick(row) {
|
|
|
+ if (this.currentIndex == -1) return;
|
|
|
+ this.current = row;
|
|
|
+ this.radio = row.id;
|
|
|
+ },
|
|
|
+ getSelectionCbom(rows = []) {
|
|
|
+ this.$emit('getSelectionCbom', rows);
|
|
|
+ this.handleClose();
|
|
|
+ },
|
|
|
+ handleClose() {
|
|
|
+ this.visible = false;
|
|
|
+ this.current = null;
|
|
|
+ this.selection = [];
|
|
|
+ this.$refs.table.clearSelection();
|
|
|
+ this.radio = '';
|
|
|
+ },
|
|
|
+
|
|
|
+ async selected() {
|
|
|
+ if (!this.current && !this.selection.length) {
|
|
|
+ return this.$message.warning('请至少选择一条数据');
|
|
|
+ }
|
|
|
+ if (this.currentIndex != -1) {
|
|
|
+ if (
|
|
|
+ this.data
|
|
|
+ .map((item) => item.productCode)
|
|
|
+ .includes(this.current.code)
|
|
|
+ ) {
|
|
|
+ return this.$message.error('选择的物品已经存在列表了');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (
|
|
|
+ this.selection.some((item) =>
|
|
|
+ this.data.some((i) => i.productCode == item.code)
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ return this.$message.error('选择的物品已经存在列表了');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ let list = this.currentIndex == -1 ? this.selection : [this.current];
|
|
|
+ console.log(list,'list')
|
|
|
+ this.$emit('changeParent', list, this.currentIndex);
|
|
|
+ this.handleClose();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+:deep(.success-row) {
|
|
|
+ background: #f0f9eb;
|
|
|
+ }
|
|
|
+ .tree_col {
|
|
|
+ border: 1px solid #eee;
|
|
|
+ padding: 10px 0;
|
|
|
+ box-sizing: border-box;
|
|
|
+ height: 500px;
|
|
|
+ overflow: auto;
|
|
|
+ }
|
|
|
+
|
|
|
+ .table_col {
|
|
|
+ padding-left: 10px;
|
|
|
+
|
|
|
+ ::v-deep .el-table th.el-table__cell {
|
|
|
+ background: #f2f2f2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .pagination {
|
|
|
+ text-align: right;
|
|
|
+ padding: 10px 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .btns {
|
|
|
+ text-align: center;
|
|
|
+ padding: 10px 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .topsearch {
|
|
|
+ margin-bottom: 15px;
|
|
|
+ }
|
|
|
+</style>
|