3328350766
6 天以前 761eb03d6b3bebd0b197179564c84d89d3d12a0d
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
<template>
  <div>
    <el-dialog
      title="输出字段配置"
      :visible.sync="dialogVisible"
      width="1000px"
      append-to-body
      :close-on-click-modal="false"
      :before-close="handleClose"
      class="bs-dialog-wrap bs-el-dialog"
    >
      <div class="bs-table-box">
        <el-table
          :data="insideFieldList"
          :border="true"
          align="center"
          class="bs-el-table"
        >
          <el-empty slot="empty" />
          <el-table-column
            align="left"
            show-overflow-tooltip
            prop="fieldName"
            label="字段值"
          />
          <el-table-column
            align="center"
            prop="fieldDesc"
            label="字段描述"
          >
            <template slot-scope="scope">
              <el-input
                v-model="scope.row.fieldDesc"
                size="small"
                class="labeldsc bs-el-input"
              />
            </template>
          </el-table-column>
          <!-- 添加一个插槽,供其他人可扩展表格列,并把表格列的数据返回出去 -->
          <slot name="output-field-table-column" />
        </el-table>
      </div>
      <span
        slot="footer"
        class="dialog-footer"
      >
        <el-button
          class="bs-el-button-default"
          @click="cancelField"
        >
          取消
        </el-button>
        <el-button
          type="primary"
          @click="setField"
        >
          确定
        </el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
import cloneDeep from 'lodash/cloneDeep'
export default {
  name: 'OutputFieldDialog',
  props: {
    outputFieldList: {
      type: Array,
      default: () => []
    }
  },
  data () {
    return {
      dialogVisible: false,
      structurePreviewListCopy: [],
      // 内部的输出字段列表 用于编辑
      insideFieldList: []
    }
  },
  methods: {
    open () {
      this.insideFieldList = cloneDeep(this.outputFieldList)
      this.dialogVisible = true
    },
    close () {
      this.dialogVisible = false
    },
    handleClose () {
      this.dialogVisible = false
    },
    cancelField () {
      this.dialogVisible = false
    },
    setField () {
      if (this.insideFieldList.length) {
        this.fieldDesc = {}
        this.insideFieldList.forEach(key => {
          this.fieldDesc[key.fieldName] = key.fieldDesc
        })
        this.$emit('setFieldList', this.insideFieldList)
      } else {
        this.fieldDesc = null
      }
      this.dialogVisible = false
    }
  }
}
</script>
 
<style lang="scss" scoped>
@import '../../../assets/style/bsTheme.scss';
</style>