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
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
<!--
 * @Author: your name
 * @Date: 2019-10-21 15:40:58
 * @LastEditTime: 2019-12-10 13:51:49
 * @LastEditors: PengJianTian
 * @Description: In User Settings Edit
 * @FilePath: /e:\Demo\cts-web\src\views\area\enterprise\update\ApplyInfo.vue
 -->
<template>
  <div class="dataBack" v-loading="loading">
    <el-form label-position="right" :model="form" v-show="!loading" ref="form">
      <el-row>
        <p class="title">申请信息</p>
        <el-col :md="12" :lg="8">
          <el-form-item label="申请编号">
            <el-input v-model="form.serialNo" readonly></el-input>
          </el-form-item>
        </el-col>
        <el-col :md="12" :lg="8">
          <el-form-item label="企业准入类型">
            <el-input v-model="form.enterpriseAccessType" readonly></el-input>
          </el-form-item>
        </el-col>
        <el-col :md="12" :lg="8">
          <el-form-item label="公司类型">
            <el-input v-model="form.companyType" readonly></el-input>
          </el-form-item>
        </el-col>
        <el-col :md="12" :lg="8">
          <el-form-item label="申请人姓名">
            <el-input v-model="form.applyName" readonly></el-input>
          </el-form-item>
        </el-col>
        <el-col :md="12" :lg="8">
          <el-form-item label="申请人工号">
            <el-input v-model="form.applyUserId" readonly></el-input>
          </el-form-item>
        </el-col>
        <el-col :md="12" :lg="8">
          <el-form-item label="申请人直属机构">
            <el-input v-model="form.applyOrgName" readonly></el-input>
          </el-form-item>
        </el-col>
        <el-col :md="12" :lg="8">
          <el-form-item label="申请人所属一级内部机构">
            <el-input v-model="form.applyFirstLevelOrgName" readonly></el-input>
          </el-form-item>
        </el-col>
        <el-col :md="12" :lg="8">
          <el-form-item label="申请时间">
            <el-input v-model="form.applyDate" readonly></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
      <el-row>
        <p class="title" v-if="!loading">开通产品信息</p>
        <product-info-table :object-no="enterpriseParams.tempSerialNo" :object-type="enterpriseParams.objectType"></product-info-table>
      </el-row>
    <el-form label-position="right" :model="creditForm" v-show="!loading" ref="form">
      <el-row>
        <p class="title" v-show="creditFrom">授信信息</p>
        <div ref="creditFrom">
          <EnpInputFixed :config.sync="creditForm.creditsum" @valueToFixed="valueToFixed"></EnpInputFixed>
          <enp-select :config.sync="creditForm.creditterm"></enp-select>
          <enp-input :config.sync="creditForm.creditopinion"></enp-input>
          <enp-input :config.sync="creditForm.serialno"></enp-input>
        </div>
      </el-row>
    </el-form>
  </div>
</template>
 
<script>
import { qryEnterpriseApplyInfo, qryEnpCreditInfo, updateEnpCreditInfo } from '@/api/area/enterprise'
import EnpSelect from '../components/EnpSelect'
import EnpInput from '../components/EnpInput'
import EnpInputFixed from '../components/EnpInputFixed'
import ProductInfoTable from './components/ProductInfoTable'
import { mapState } from 'vuex'
 
import { communal } from '@/views/area/mixins'
export default {
  components: { EnpSelect, ProductInfoTable, EnpInput, EnpInputFixed },
  props: ['nextChange'],
  mixins: [ communal ],
  data: function() {
    return {
      loading: true,
      creditFrom: true,
      form: {
        serialNo: '',
        applyName: '',
        applyUserId: '',
        applyOrgId: '',
        applyOrgName: '',
        enterpriseAccessType: '',
        applyFirstLevelOrgId: '',
        applyFirstLevelOrgName: '',
        applyDate: '',
        companyType: ''
      },
      creditForm: {
        creditopinion: '',
        creditsum: '',
        creditterm: '',
        serialno: '',
      },
      oldForm: {}
    }
  },
  watch: {
    'creditForm.creditsum': function(val) {
      // 不可编辑
      if (!val.writeAble && val.value) {
        let valCount = val.value * 1
        this.creditForm.creditsum.value = valCount.toFixed(2).toString()
        this.oldForm.creditsum.value = valCount.toFixed(2).toString()
      }
    }
  },
  created() {
    this.initForm()
  },
  computed: {
    ...mapState({
      enterpriseParams: state => state.risk.enterpriseParams
    })
  },
  methods: {
    // 初始化
    async initForm() {
      let params = {
        serialno: this.enterpriseParams.tempSerialNo
      }
      let res = await qryEnterpriseApplyInfo(params)
      this._.merge(this.form, res.result)
      let creditRes = await qryEnpCreditInfo(params)
      this._.merge(this.creditForm, creditRes.result)
      // if (this.creditForm.creditsum.value) {
      //   this.creditForm.creditsum.value = this.creditForm.creditsum.value * 1
      //   this.creditForm.creditsum.value = this.creditForm.creditsum.value.toFixed(2)
      // }
      // console.log(this.creditForm.creditsum.value.toFixed(2))
      Object.assign(this.oldForm, creditRes.result)
      this.$nextTick(() => {
        this.creditFrom = Boolean(this.$refs['creditFrom'].getElementsByClassName('el-col').length > 0)
      })
 
      this.loading = false
    },
    // 保存草稿
    handleSaveDraft() {
      // let params = {}
      // Object.keys(this.creditForm).forEach(key => {
      //   params[key] = this.creditForm[key].value
      // })
      // params.checkFlag = false
      // updateEnpCreditInfo(params).then(res => {
      //   if (res.code === '00') {
      //     this.$message.success('保存成功!')
      //   }
      // })
      this.$message.success('保存成功!')
      this.oldForm = Object.assign(this.oldForm, this.form)
    },
    // 保存
    handleSave() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          let params = {}
          Object.keys(this.creditForm).forEach(key => {
            params[key] = this.creditForm[key].value
          })
          params.checkFlag = true
          updateEnpCreditInfo(params).then(res => {
            if (res.code === '00') {
              this.$message.success('保存成功')
              // this.$emit('handleNextPage', true)
              this.oldForm = Object.assign(this.oldForm, this.creditFrom)
            }
          })
        } else {
          this.$message.warning('当前页面存在必填项未录入或数据录入错误,请检查!')
          return false
        }
      })
    },
    // 表单提交
    handleSubmit() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          let params = {}
          Object.keys(this.creditForm).forEach(key => {
            params[key] = this.creditForm[key].value
          })
          params.checkFlag = true
          updateEnpCreditInfo(params).then(res => {
            if (res.code === '00') {
              // this.$message.success('提交成功!')
              this.$emit('handleNextPage', true)
            }
          })
        } else {
          this.$message.warning('当前页面存在必填项未录入或数据录入错误,请检查!')
          return false
        }
      })
    },
    // 可编辑授信额度
    valueToFixed(value) {
      const { creditsum } = this.creditForm
      if (creditsum.writeAble && value !== '') {
        if (!isNaN(value)) {
          this.creditForm.creditsum.value = this.formatMoney(value)
          // console.log(this.formatMoney(value))
        } else {
          this.$message.warning('非法输入,请输入正确的金额!')
           this.creditForm.creditsum.value = ''
          // this.oldForm.creditsum.value = ''
        }
      }
    }
  },
  beforeRouteLeave (to, from, next) {
    // console.log(this.creditForm)
    // console.log(this.oldForm)
    // console.log(this.nextChange)
    if (this.nextChange) {
      for (const key in this.oldForm) {
        if (this.oldForm.hasOwnProperty(key)) {
          if (this.oldForm[key].value != this.creditForm[key].value) {
            // console.log(this.oldForm[key].value)
            // console.log(this.creditForm[key].value)
            this.$confirm(`当前页面有未保存的数据,是否放弃保存`, '提示', {
              confirmButtonText: '是',
              cancelButtonText: '否',
              customClass: 'enp_messages_box',
              confirmButtonClass: 'enp_messages_box_confirm',
              cancelButtonClass: 'enp_messages_box_cancel',
              center: true
            })
              .then(() => {
                next()
              })
              .catch(() => {
                this.$emit('notNext')
              })
            return
          }
        }
      }
    }
    next();
  }
}
</script>
 
<style lang="stylus" scoped>
.title
    margin-top 22px
</style>