田源
2024-01-31 78a699eb4c46aa2e8cd4c72fc6a9d4c5bf3a9fcf
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<template>
  <div v-if="dialogVisible">
    <el-dialog :before-close="EscHandlerClose" :title="dialogTitleName" :visible.sync="dialogVisible" append-to-body>
      <template>
        <el-select v-model="SelectValue" placeholder="请选择" style="width: 135px">
          <el-option
            v-for="item in SelectOption"
            :key="item.key"
            :label="item.label"
            :value="item.value"
            style="width: 150px">
          </el-option>
        </el-select>
        <el-input v-model="SelectSearchValue" placeholder="输入值后进行模糊查询"
                  style="width: 260px;margin-left: 15px"></el-input>
        <el-button plain size="small" style="margin-left: 20px" type="primary" @click="SelectSearchHandler">查询
        </el-button>
      </template>
      <avue-crud :data="TableData" :option="this.codeType === 'btmCode' ? this.btmOption : this.option" @row-click="rowHandlerClick" :table-loading="loading">
        <template slot="radio" slot-scope="{row}">
          <el-radio v-model="radioValue" :label="row.$index" style="padding-left: 10px !important;">{{ '' }}
          </el-radio>
        </template>
      </avue-crud>
      <div style="height: 30px">
        <div
          style="display: inline-block;float: left;border: 1px solid #eeeeee;padding: 5px;margin-top: 5px;font-size: 14px ">
          已设置的值为:[{{ this.TreeAddform[codeName] == '' ? '未设置值' : this.TreeAddform[codeName] }}]
        </div>
        <div style="padding-top: 10px;display: flex; justify-content: flex-end;float: right;overflow: hidden">
          <el-button size="small" type="primary" @click="HandlerClickSave">确定</el-button>
          <el-button size="small" @click="HandlerClickEsc">取消</el-button>
        </div>
      </div>
    </el-dialog>
  </div>
</template>
 
<script>
import {defaultReferDataGrid, referDataGrid} from '@/api/MasterData/master'
 
export default {
  name: "ThemeChildren",
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
    SelectOption: {
      type: Array,
    },
    dialogTitle: {
      type: String
    },
    TreeAddform: {
      type: Object
    },
    codeName: {
      type: String
    },
    codeType: {
      type: String
    },
    codeLcstatus: {
      type: String
    }
  },
  data() {
    return {
      SelectValue: 'id',
      SelectSearchValue: '',
      radioValue: '',
      LineParm: {},
      crudName: '',
      crudOid: '',
      TableData: [],
      loading:false,
      option: {
        addBtn: false,
        index: true,
        columnBtn: false,
        refreshBtn: false,
        border: true,
        menu: false,
        height: 380,
        rowKey: "oid",
        column: [
          {
            label: '',
            prop: 'radio',
            width: 60,
            display: false
          },
          {
            label: '英文名称',
            prop: 'id'
          },
          {
            label: '中文名称',
            prop: 'name'
          },
          {
            label: '描述',
            prop: 'description'
          }
        ]
      },
      btmOption:{
        addBtn: false,
        index: true,
        columnBtn: false,
        refreshBtn: false,
        border: true,
        menu: false,
        height:380,
        rowKey: "oid",
        column:[
          {
            label: '',
            prop: 'radio',
            width: 60,
            display: false
          },
          {
            label:'业务类型编号',
            prop:'id'
          },
          {
            label:'业务类型名称',
            prop:'name'
          },
          {
            label:'描述',
            prop:'description'
          }
        ]
      },
    }
  },
  created() {
    this.loading = true;
  },
  mounted() {
  },
  computed: {
    dialogVisible: {
      get() {
        return this.visible;
      },
      set(val) {
        this.$emit("update:visible", val);
      },
    },
    dialogTitleName() {
      return `为【${this.dialogTitle}】选取值`;
    },
  },
  methods: {
    //关闭表单
    EscHandlerClose() {
      this.dialogVisible = false;
      this.SelectSearchValue = '';
      this.SelectValue = 'id';
      this.radioValue = null;
      this.LineParm = {};
    },
    // 模糊查询
    SelectSearchHandler() {
      this.loading = true;
      if (!this.SelectOption || this.SelectOption.length === 0) {
        this.loading = false;
        return;
      }
      const Parameter = {};
      const DefaultParameter = {};
      Parameter[`conditionMap['${this.SelectValue}']`] = this.SelectSearchValue;
      DefaultParameter[`conditionMap['${this.SelectValue}_like']`] = this.SelectSearchValue;
      if(this.codeType === "btmCode"){
        this.btmDefaultRend(Parameter)
      }else {
        this.defaultSearchRend(DefaultParameter);
      }
    },
    //表格行单选
    rowHandlerClick(row) {
      this.radioValue = row.$index;
      this.LineParm = row;
      this.crudName = row.name;
      this.crudOid = this.codeType === 'btmCode' ? row.id : row.oid;
    },
    //确定
    HandlerClickSave() {
      if (Object.values(this.LineParm).length === 0) {
        this.$message.warning('请至少选择一条数据!')
      } else {
        this.EscHandlerClose();
        this.$emit('defineHandler', { crudName: this.crudName, crudOid: this.crudOid ,codeType:this.codeType});
      }
    },
    //取消
    HandlerClickEsc() {
      this.EscHandlerClose()
    },
    //接口
    defaultSearchRend(Parameter) {
      defaultReferDataGrid({
        referType: this.codeType,
        isMuti: 'false',
        'conditionMap["lcstatus"]': this.codeLcstatus,
        'limit': '-1',
        ...Parameter
      }).then(res => {
        this.TableData = res.data.records;
        this.loading = false;
      })
    },
    btmDefaultRend(Parameter) {
      referDataGrid({valueField: 'id', isMuti: 'false', 'limit': '-1', ...Parameter}).then(res => {
        this.TableData = res.data.data.records;
        this.loading = false;
      })
    },
  }
}
</script>
 
<style scoped>
 
</style>