zhaoxiaoqiang1
2026-01-04 f1d30d03186c79ca2cbcfe60d6d2ce7d73fba97b
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
<template>
  <div class="customer-edit">
    <el-dialog :title="title"
               :visible.sync="dialogVisible"
               :modal-append-to-body="false"
               :close-on-click-modal="false"
               :before-close="handleClose"
               custom-class="comm-dialog"
               center
               width="850px">
      <EditForm ref="contractForm"
                column="2"
                :inline="true"
                :list="formList"
                :formValues="formValues"
                :formRules="formRules"
                :key="info.mailingNo || '1'"
                @updateValue="updateValue"></EditForm>
      <div slot="footer"
           class="dialog-footer popup-form-buttons">
        <el-button class="comm-button"
                   size="small"
                   @click="$emit('doAction', 'close')">取消</el-button>
        <el-button class="comm-button"
                   size="small"
                   @click="submit"
                   type="primary">保存</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
// 返现开发商-新增与编辑
import EditForm from '../components/EditForm';
import addOrModifyCommissionTransferFlow from '@comprehensive/model/addOrModifyCommissionTransferFlow';
import queryCommissionPorjectAll from '@comprehensive/model/queryCommissionPorjectAll';
export default {
  components: {
    EditForm,
  },
  props: {
    dialogVisible: {
      type: Boolean,
      default: false,
    },
    title: {
      type: String,
      default: '新增',
    },
    info: {
      type: Object,
      default: () => ({}),
    },
    commissionDeveloperAll: {
      type: Array,
      default: () => ([]),
    },
    // commissionPorjectAll: {
    //   type: Array,
    //   default: () => ([]),
    // },
    commissionTaxiSourceAll: {
      type: Array,
      default: () => ([]),
    },
  },
  data() {
    return {
      loading: false,
      model: null,
      formRules: {},
      formList: [],
      commissionPorjectAll: []
    };
  },
  created() {
    this.init();
  },
  methods: {
    init() {
      const { info } = this;
      const model = addOrModifyCommissionTransferFlow();
      this.model = model;
      const formList = model.getFormList({
        ...info,
        address: info.adress || info.address || '',
      });
      this.formList = formList;
      this.formRules = model.getFormRules(formList);
      // this.setOptions();
    },
 
    setOptions() {
      this.updateValue('developerId', { options: this.commissionDeveloperAll });
      // this.updateValue('projectId', { options: this.commissionPorjectAll });
      this.updateValue('taxiSourceId', { options: this.commissionTaxiSourceAll });
    },
    // 更新表单数据 info->当前选项初始值
    updateValue(index, info, flag) {
      const { formList } = this;
      if (isNaN(index)) {
        // index is name
        index = formList.findIndex(({ name }) => name === index);
      }
      if (!isNaN(index) && index > -1) {
        const preInfo = formList[index];
        this.$set(formList, index, { ...preInfo, ...info });
        if (preInfo.name === 'developerId' && formList[index].value) {
          this.queryCommissionPorjectAll(formList[index].value)
          if(info.value != preInfo.value && info.value) {
            this.$set(formList, 2, { ...formList[2], value: '' });
            this.$set(formList, 3, { ...formList[3], value: '' });
          }
        }
        if (preInfo.name === 'projectId') {
          const infoFind = this.commissionPorjectAll.find(item => {
            return item.value === formList[index].value
          })
          // 设置项目别名
          infoFind && this.updateValue('projectAlias', { value: infoFind.projectAlias });
        }
      }
    },
    
    // 项目下拉列表
    async queryCommissionPorjectAll(developerId) {
      const res = await queryCommissionPorjectAll().request({developerId});
      const { list } = res;
      console.log(list)
      this.commissionPorjectAll = list;
      this.updateValue('projectId', { options: list });
    },
    async submit() {
      const { model, info } = this;
      let formInfo = this.$refs.contractForm.validate();
      console.log('--', formInfo)
      if (formInfo) {
        // if ('serialno' in info) {
        //   formInfo.serialno = info.serialno;
        // }
        this.loading = true;
        await model.request({
          ...formInfo,
        });
        this.$emit('doAction', 'succ');
        this.loading = false;
      }
    },
    handleClose(done) {
      this.$emit('doAction', 'close')
    }
  },
  computed: {
    // 表单值信息
    formValues() {
      const { model, formList } = this;
      return model.getFormValues(formList);
    },
  },
  watch: {
    info() {
    },
    dialogVisible(newV) {
      if(newV) {
        console.log(newV)
        this.init();
        this.setOptions()
      }
    }
  },
};
</script>
<style lang="postcss" scoped>
.disable-input {
  background-color: #f5f7fa;
  border: 1px solid #f5f7fa;
  border-radius: 4px;
  color: #c0c4cc;
  cursor: pointer;
  width: 190px;
  height: 32px;
  line-height: 32px;
  padding: 0 15px;
  display: flex;
  justify-content: space-between;
  & p {
    flex: 1;
  }
  & >>> .el-icon-tickets {
    line-height: 34px;
  }
}
.customer-edit {
  & >>> .el-dialog__header {
    padding-bottom: 0;
  }
  & >>> .el-dialog__body {
    padding-top: 0;
  }
  & >>> .el-dialog {
    width: 950px;
  }
}
</style>