wente
2024-07-01 37dd841d6269e185a1a1420f852e5b097528754b
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
<template>
  <zt-dialog ref="dialog" @confirm="formSubmit" column='2' append-to-body class="pub_dialog">
    <el-row :gutter="24" style="height: 700px;overflow: auto">
      <el-col :span="24">
        <el-form :model="dataForm" ref="dataForm" :disabled="dataForm.disabled" label-width="120px"
                 label-position="left" size="mini">
          <el-row :gutter="20">
            <el-col :span="12">
              <zt-form-item label="源" prop="src" rules="required">
                <zt-select v-model="dataForm.src" :datas="srcList" placeholder="源" @change="changeSelect"></zt-select>
                <!--            <zt-dict v-model="dataForm.src" dict="company_type" placeholder="源" @input="changeSelect"></zt-dict>
                -->
              </zt-form-item>
            </el-col>
            <el-col :span="12">
              <zt-form-item label="目的" prop="dst" class="role-list" rules="required">
                <zt-select v-model="dataForm.dst" :datas="dstList" placeholder="目的" @change="changeSelect"></zt-select>
                <!--           <zt-dict v-model="dataForm.dst" dict="company_type" placeholder="目的" @input="changeSelect"></zt-dict>
                -->
              </zt-form-item>
            </el-col>
          </el-row>
          <!-- <zt-form-item label="数据库名称" prop="databasename">
        <zt-dict v-model="dataForm.databasename" placeholder="数据库名称" dict="sync_config_databasename_type"></zt-dict>
      </zt-form-item> -->
 
          <!-- <zt-form-item label="主键字段名" prop="pkField">
        <el-input v-model="dataForm.pkField" placeholder="主键字段名"></el-input>
      </zt-form-item> -->
          <!--<el-row :gutter="20">
            <el-col :span="12">
              <zt-form-item label="数据等级" prop="datalevel">
                <el-input v-model="dataForm.datalevel" placeholder="数据等级"></el-input>
              </zt-form-item>
            </el-col>
            <el-col :span="12">
              <zt-form-item label="数据传递方向" prop="direct">
                <el-input v-model="dataForm.direct" placeholder="数据传递方向"></el-input>
              </zt-form-item>
            </el-col>
          </el-row>-->
 
          <el-row :gutter="20">
            <el-col :span="12">
              <zt-form-item label="序号" prop="sortno">
                <el-input type="number" v-model="dataForm.sortno" placeholder="序号"></el-input>
              </zt-form-item>
            </el-col>
            <el-col :span="12">
              <zt-form-item label="不传递字段" prop="fieldlist">
                <el-input v-model="dataForm.fieldlist" placeholder="不传递字段','分隔"></el-input>
              </zt-form-item>
            </el-col>
          </el-row>
 
          <el-row :gutter="20">
            <el-col :span="24">
              <zt-form-item prop="timecond" label="按时间范围过滤">
                <!-- <el-checkbox v-model="dataForm.timecond" true-label="0" false-label="1">按时间范围过滤</el-checkbox> -->
                <el-switch v-model="dataForm.timecond"></el-switch>
              </zt-form-item>
            </el-col>
          </el-row>
 
          <!--          <el-row :gutter="20">
                      <el-col :span="8">
                        <zt-form-item prop="productCond" label="按产品节点过滤">
                          &lt;!&ndash; <el-checkbox v-model="dataForm.productCond" true-label="0" false-label="1">按产品节点过滤</el-checkbox> &ndash;&gt;
                          <el-switch v-model="dataForm.productCond"></el-switch>
                        </zt-form-item>
                      </el-col>
                      <el-col :span="8">
                        <zt-form-item label="产品节点ID字段" prop="productfield">
                          <el-input v-model="dataForm.productfield" placeholder="产品节点ID字段"></el-input>
                        </zt-form-item>
                      </el-col>
                      <el-col :span="8">
                        <zt-form-item label="产品数据ID字段" prop="productdatafield">
                          <el-input v-model="dataForm.productdatafield" placeholder="产品数据ID字段"></el-input>
                        </zt-form-item>
                      </el-col>
                    </el-row>-->
 
          <!--          <el-row :gutter="20">
                      <el-col :span="12">
                        <zt-form-item prop="companyCond" label="按厂家过滤">
                          &lt;!&ndash; <el-checkbox v-model="dataForm.companyCond" true-label="0" false-label="1">按厂家过滤</el-checkbox> &ndash;&gt;
                          <el-switch v-model="dataForm.companyCond"></el-switch>
                        </zt-form-item>
                      </el-col>
 
                      <el-col :span="12">
                        <zt-form-item label="厂家字段名称" prop="fkField">
                          <el-input v-model="dataForm.fkField" placeholder="厂家字段名称"></el-input>
                        </zt-form-item>
                      </el-col>
                    </el-row>-->
 
          <el-row :gutter="20">
            <el-col :span="12">
              <zt-form-item label="按其他条件过滤" prop="otherCond" class="role-list">
                <!-- <zt-select v-model="dataForm.otherCond" url="/maintain/SyncConfig/getTableNameList" placeholder="按其他条件过滤"></zt-select> -->
                <!-- <el-input v-model="dataForm.otherCond" placeholder="按其他条件过滤"></el-input> -->
                <el-select v-model="dataForm.otherCond" placeholder="按其他条件过滤">
                  <el-option v-for="item in otherCondList" :key="item.value" :label="item.label" :value="item.value">
                  </el-option>
                </el-select>
              </zt-form-item>
            </el-col>
            <el-col :span="12">
              <zt-form-item label="其他条件外键" prop="otherTermKey">
                <el-input v-model="dataForm.otherTermKey" placeholder="其他条件外键"></el-input>
              </zt-form-item>
            </el-col>
          </el-row>
 
          <el-row :gutter="20">
            <el-col :span="24">
              <zt-form-item label="附件条件sql" prop="addcond">
                <el-input type="textarea" v-model="dataForm.addcond" placeholder="附件条件sql" show-word-limit
                          rows="4"></el-input>
              </zt-form-item>
            </el-col>
            <!-- <el-col :span="12">
              <zt-form-item label="相关状态处理" prop="relatedStateHandle">
                <el-input v-model="dataForm.relatedStateHandle" placeholder="相关状态处理"></el-input>
              </zt-form-item>
            </el-col> -->
          </el-row>
          <!-- <el-row :gutter="20">
            <el-col :span="24">
              <zt-form-item label="相关状态处理" prop="labelPosition">
                <el-radio-group v-model="dataForm.labelPosition" size="small">
                  <el-radio-button label="0">否</el-radio-button>
                  <el-radio-button label="1">前</el-radio-button>
                  <el-radio-button label="2">后</el-radio-button>
                </el-radio-group>
              </zt-form-item>
            </el-col>
          </el-row> -->
          <!--          <el-row :gutter="20">-->
          <!--            <el-col :span="24">-->
          <!--              <zt-form-item label="相关状态处理" prop="relatedStateHandle">-->
          <!--                <el-input type="textarea" v-model="dataForm.relatedStateHandle" placeholder="相关状态处理','分隔" show-word-limit rows="4"></el-input>-->
          <!--              </zt-form-item>-->
          <!--            </el-col>-->
          <!--          </el-row>-->
          <el-row :gutter="20">
            <el-col :span="24">
              <zt-form-item label="规则说明" prop="tabledesc">
                <el-input type="textarea" maxlength="600" v-model="dataForm.tabledesc" placeholder="规则说明"
                          show-word-limit rows="4"></el-input>
              </zt-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="24">
              <zt-form-item label="是否启用" prop="relatedDataFlow">
                <el-switch v-model="dataForm.relatedDataFlow"></el-switch>
              </zt-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-col>
      <el-col :span="24" class="tran">
        <el-transfer style="margin-left: 15%;" v-model="dataForm.syncConfigTableList" :titles="['未关联', '已关联']"
                     :data="tableNameList"></el-transfer>
      </el-col>
    </el-row>
  </zt-dialog>
</template>
 
<script>
  export default {
    data() {
      return {
        dataForm: {
          id: '',
          databasename: '',
          tablename: '',
          tabledesc: '',
          pkField: '',
          fkField: '',
          datalevel: '',
          direct: '',
          sortno: 1,
          src: '',
          dst: '',
          productfield: '',
          productdatafield: '',
          ismarkfield: '',
          fieldlist: '',
          timecond: false,
          addcond: '',
          otherTermKey: '',
          relatedStateHandle: '',
          relatedDataFlow: true,
          productCond: false,
          companyCond: false,
          otherCond: '',
          syncConfigTableList: [],
          syncConfigTableRigthList: [],
          labelPosition: 0
        },
        srcList: [{id: 'cj', name: '厂家'}, {id: 'jd', name: '基地'}],
        dstList: [{id: 'cj', name: '厂家'}, {id: 'jd', name: '基地'}, {id: 'yjs', name: '研究所'}],
        tableNameList: [],
        otherCondList: [],
        isOne: true,
      }
    },
    methods: {
      init(id) {
        this.isOne = true
        this.dataForm.id = id
        if (this.dataForm.id === null || this.dataForm.id === undefined) {
          this.dataForm.id = ''
          this.getListInfo()
        }
      },
      // 获取信息
      async getInfo() {
        let res = await this.$http.get(
          `/maintain/SyncConfig/${this.dataForm.id}`
        )
        this.dataForm = {
          ...this.dataForm,
          ...res.data
        }
        this.getOtherCondList()
        this.getListInfo()
      },
      // 获取列表信息
      async getListInfo() {
        this.tableNameList = []
        let res = await this.$http.post(
          '/sys/data/export/record/tname',
          this.dataForm
        )
        if (res.success) {
          this.tableNameList = res.data.dataList
          this.dataForm.syncConfigTableList =
            res.data.rightChecked === null ? [] : res.data.rightChecked
        }
      },
      changeSelect() {
        this.otherCondList = []
        this.dataForm.otherCond = ''
        this.getOtherCondList()
        this.getListInfo()
      },
      async getOtherCondList() {
        if (
          this.dataForm.src !== null &&
          this.dataForm.src !== '' &&
          this.dataForm.src !== undefined &&
          this.dataForm.dst !== null &&
          this.dataForm.dst !== '' &&
          this.dataForm.dst !== undefined
        ) {
          let data = {
            src: this.dataForm.src,
            dst: this.dataForm.dst,
            id:
              this.dataForm.id !== null &&
              this.dataForm.id !== '' &&
              this.dataForm.id !== undefined
                ? this.dataForm.id
                : ''
          }
          let res = await this.$http.post(
            '/sys/data/export/record/otherCond',
            data
          )
          if (res.success) {
            this.otherCondList = res.data
          }
        }
      },
      // 表单提交
      async formSubmit() {
        if(this.isOne){
          this.isOne= false
          let configArr = []
          this.dataForm.syncConfigTableList.forEach((element) => {
            configArr.push(JSON.parse('{"tableName":"' + element + '"}'))
          })
          this.dataForm.syncConfigTableList = configArr
          let res = await this.$http[!this.dataForm.id ? 'post' : 'put']('/maintain/SyncConfig/', this.dataForm)
          if (res.success) {
 
            await this.$tip.success()
            this.$refs.dialog.close()
            this.$emit('refreshDataList')
          }
        }
      },
      leftCheckChange(value, movedKeys) {
        // window.console.log(value, movedKeys)
        /*
        // 左侧数据
        this.tableNameList.push(movedKeys)
        // 右侧数据
        this.dataForm.syncConfigTableList.push({
          key: movedKeys[0] + '',
          label: movedKeys[0] + ''
        }) */
      },
      rightCheckChange(value, movedKeys) {
        window.console.log(value, movedKeys)
      }
    }
  }
</script>
<style lang="scss">
  .tran .el-transfer-panel {
    width: 33%;
    height: 500px;
    margin: 10px;
  }
 
  .tran .el-transfer-panel__list {
    height: 460px;
  }
</style>