plm前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
2.9 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <script>
  2. import {chooseList} from "../../../api/chooselist/chooselist";
  3. export default {
  4. name: "chooseListDemo",
  5. props:{
  6. searchList:{
  7. type: Array,
  8. required:true
  9. },
  10. columnList:{
  11. type: Array,
  12. required: true,
  13. },
  14. tagNo:{
  15. type: String,
  16. required: true
  17. },
  18. useSite:{
  19. type:Boolean,
  20. default: true,
  21. }
  22. },
  23. data(){
  24. return{
  25. searchModel:{},
  26. chooseListData:[],
  27. visible:false
  28. }
  29. },
  30. methods:{
  31. openChooseList(){
  32. this.searchList.forEach((item)=>{
  33. this.searchModel = {}
  34. this.$nextTick(() => {
  35. this.$set(this.searchModel, item.value, undefined);
  36. });
  37. })
  38. this.searchBtn()
  39. },
  40. closeChooseList(){
  41. this.chooseListData = [];
  42. },
  43. searchBtn(){
  44. let params = JSON.parse(JSON.stringify(this.searchModel))
  45. params.tagNo = this.tagNo
  46. params.columnList = this.columnList.map((item)=>item.columnProp)
  47. params.site = this.useSite?this.$store.state.user.site:''
  48. chooseList(params).then(({data})=>{
  49. if (data && data.code === 0){
  50. this.chooseListData = data.baseListData;
  51. }else {
  52. this.$message.error(data.msg)
  53. }
  54. })
  55. },
  56. getRowData(row) {
  57. this.visible = false
  58. this.$emit('getBaseData',row)
  59. },
  60. init(){
  61. this.visible = true
  62. }
  63. },
  64. }
  65. </script>
  66. <template>
  67. <div class="chooseListDemo">
  68. <el-dialog v-bind="$attrs" :visible.sync="visible" v-on="$listeners" @open="openChooseList" @close="closeChooseList">
  69. <el-form :model="searchModel" label-position="top">
  70. <el-row :gutter="20">
  71. <el-col :span="6" v-for="(item,index) in searchList" :key="index">
  72. <el-form-item :label="item.label">
  73. <el-input v-model="searchModel[item.value]" clearable></el-input>
  74. </el-form-item>
  75. </el-col>
  76. <el-col :span="6">
  77. <el-form-item label=" ">
  78. <el-button type="primary" @click="searchBtn">查询</el-button>
  79. </el-form-item>
  80. </el-col>
  81. </el-row>
  82. </el-form>
  83. <el-table
  84. height="30vh"
  85. :data="chooseListData"
  86. border @row-dblclick="getRowData"
  87. style="width: 100%;">
  88. <el-table-column
  89. v-for="(item,index) in columnList" :key="index"
  90. :sortable="item.columnSortable"
  91. :prop="item.columnProp"
  92. :header-align="item.headerAlign"
  93. :show-overflow-tooltip="item.showOverflowTooltip"
  94. :align="item.align"
  95. :fixed="item.fixed===''?false:item.fixed"
  96. :min-width="item.columnWidth"
  97. :label="item.columnLabel">
  98. <template slot-scope="scope">
  99. {{ scope.row[item.columnProp] }}
  100. </template>
  101. </el-table-column>
  102. </el-table>
  103. <span slot="footer" class="dialog-footer">
  104. </span>
  105. </el-dialog>
  106. </div>
  107. </template>
  108. <style scoped>
  109. </style>