<template>
|
<div class="edit-selClient-box">
|
<el-dialog
|
:title="editCommonConfig.title"
|
:visible.sync="editConfig.editVisible"
|
:width="dialogWidth"
|
:before-close="handleClose"
|
:append-to-body="true"
|
:close-on-click-modal="false"
|
>
|
<div class="bg-view">
|
<div class="query-bg">
|
<!-- <el-input placeholder="请输入内容" v-model="queryInput" size="mini" class="input-with-select">
|
<el-select v-model="select" slot="prepend" placeholder="请选择">
|
<el-option v-for="item in commonOptions" :key="item.id" :label="item.name" :value="item.name">
|
</el-option>
|
</el-select>
|
</el-input> -->
|
<SearchCommonView
|
ref="searchCommonView"
|
:search-options="searchOptions"
|
@searchClick="searchClick"
|
@resetClick="resetClick"
|
:search-sel="searchSel"
|
/>
|
<div class="btn">
|
<!-- <el-button type="primary" size="mini" disabled>设置字段</el-button>
|
<el-button type="primary" size="mini" disabled>快速创建</el-button> -->
|
</div>
|
</div>
|
<TableCommonView ref="tableListRef" :table-list="tableList" :select-box="false" @selCommonClick="selNameClick">
|
</TableCommonView>
|
<div slot="footer" class="dialog-footer">
|
<div class="remark">说明:支持多字段模糊查询,仅显示符合条件的前5条数据</div>
|
</div>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import { getProductListFromGrpc } from "@/api/productManage/product"
|
export default {
|
name: "EditSelCommonDialog",
|
props: {
|
editCommonConfig: {
|
type: Object,
|
default: () => {
|
return {
|
editVisible: false,
|
title: "",
|
tableInfomation: []
|
}
|
}
|
}
|
},
|
components: {},
|
computed: {},
|
data() {
|
return {
|
dialogWidth: "50%",
|
editConfig: this.editCommonConfig,
|
queryInput: "",
|
select: "全部字段",
|
tableData: [],
|
searchSelOptions: [],
|
loading: false,
|
tableList: {},
|
searchOptions: [],
|
search_map: {},
|
searchSel: {},
|
keyword: "",
|
keywordType: ""
|
}
|
},
|
created() {
|
this.setTable()
|
this.getData()
|
},
|
methods: {
|
setTable() {
|
if (this.editConfig.title === "产品名称") {
|
this.tableList = {
|
tableInfomation: [],
|
tableColumn: [
|
{ label: "产品名称", prop: "name", isClick: true },
|
{ label: "产品编号", prop: "number" }
|
]
|
}
|
this.searchSel = { value: "name", label: "产品名称" }
|
}
|
this.searchOptions = []
|
for (let i = 0; i < this.tableList.tableColumn.length; i++) {
|
const label = this.tableList.tableColumn[i].label
|
const value = this.tableList.tableColumn[i].prop
|
this.searchOptions.push({ value: value, label: label })
|
}
|
},
|
// 请求数据
|
async getData() {
|
this.loading = true
|
if (this.editConfig.title === "产品名称") {
|
this.getProductList()
|
}
|
},
|
// 产品名称
|
async getProductList() {
|
await getProductListFromGrpc({
|
page: 1,
|
pageSize: 100
|
}).then((res) => {
|
console.log(res.data)
|
if (res.data.code === 200) {
|
if (res.data.data.list && res.data.data.list.length > 0) {
|
const list = res.data.data.list.map((item) => {
|
return {
|
...item
|
}
|
})
|
this.tableList.tableInfomation = list.slice(0, 5) || []
|
} else {
|
this.tableList.tableInfomation = []
|
}
|
}
|
this.loading = false
|
})
|
},
|
handleClose() {
|
this.editConfig.editVisible = false
|
},
|
selNameClick(row) {
|
this.editConfig.editVisible = false
|
if (this.editConfig.title === "产品名称") {
|
this.$emit("selClient", row, "productName")
|
}
|
},
|
// 搜索
|
searchClick(val, content) {
|
console.log(val, content)
|
this.search_map = {
|
[val.value]: content
|
}
|
this.keyword = content
|
this.keywordType = val.label
|
this.getData()
|
},
|
resetClick() {
|
this.search_map = {}
|
this.keyword = ""
|
this.keywordType = ""
|
this.getData()
|
}
|
}
|
}
|
</script>
|
|
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
<style lang="scss" scoped>
|
.bg-view {
|
margin: 10px;
|
.query-bg {
|
margin-left: -20px;
|
margin-bottom: 10px;
|
display: flex;
|
justify-content: space-between;
|
.el-input {
|
width: 310px;
|
.el-select {
|
width: 100px;
|
}
|
}
|
.btn {
|
float: right;
|
}
|
}
|
}
|
.sel-name {
|
color: $color-primary;
|
cursor: pointer;
|
}
|
.dialog-footer {
|
height: 40px;
|
line-height: 40px;
|
color: red;
|
}
|
::v-deep {
|
.input-with-select .el-input-group__prepend {
|
background-color: #fff;
|
}
|
}
|
</style>
|