jiangping
2023-10-24 349bcef9a96391d22522a3409adf5a89e7e70a95
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
<template>
  <GlobalAlertWindow
    :title="title"
    :visible.sync="visible"
    :confirm-working="isWorking"
    @confirm="confirm"
  >
    <div class="tips-style">钉钉相关配置需要进入【<a src="https://open.dingtalk.com/">钉钉开放平台</a>】配置钉钉H5应用并获取对应的参数</div>
    <el-form :model="form" ref="form" label-width="150px" label-suffix=":" :rules="rules" inline>
      <div class="short-line">
        <el-form-item label="CorpId" prop="corpId">
          <el-input v-model="form.corpId" placeholder="请输入CorpId" v-trim/>
          钉钉开放平台首页的CorpId
        </el-form-item>
      </div>
      <div class="short-line">
        <el-form-item label="AgentId" prop="agentId">
          <el-input v-model="form.agentId" placeholder="请输入AgentId" v-trim/>
          钉钉H5应用的AgentId
        </el-form-item>
      </div>
      <div class="short-line">
        <el-form-item label="app_key" prop="app_key">
          <el-input v-model="form.app_key" placeholder="请输入app_key" v-trim/>
          钉钉H5应用的app_key
        </el-form-item>
      </div>
      <div class="short-line">
        <el-form-item label="app_secret" prop="app_secret">
          <el-input v-model="form.app_secret" placeholder="请输入app_secret" v-trim/>
          钉钉H5应用的app_secret
        </el-form-item>
      </div>
    </el-form>
    <!-- <div slot="footer"></div> -->
  </GlobalAlertWindow>
</template>
 
<script>
import BaseOpera from '@/components/base/BaseOpera'
import GlobalAlertWindow from '@/components/common/GlobalAlertWindow'
import UploadImage from '../common/UploadImage.vue'
// import { create } from '@/api/business/companyChange'
import { creditCode } from '@/utils/form'
import { update } from '@/api/business/clientManger'
export default {
  name: 'OperaDDSettingWindow',
  extends: BaseOpera,
  components: { GlobalAlertWindow, UploadImage },
  data () {
    
    return {
      isUploading: false,
      // 表单数据
      form: {
        id: null,
       
        corpId: '',
        agentId: '',
        app_key: '',
        app_secret: '',
      },
      types:[],
      // 验证规则
      rules: {
        corpId: [
          { required: true, message: '请输入CorpId', trigger: 'blur' }
        ],
        agentId: [
          { required: true, message: '请输入AgentId', trigger: 'blur' }
        ],
        app_key: [
          { required: true, message: '请输入app_key', trigger: 'blur' }
        ],
        app_secret: [
          { required: true, message: '请输入app_secret', trigger: 'blur' }
        ],
        // fileList: [
        //   { required: true, message: '请输入上传', trigger: 'change' }
        // ],
        companyShortName: [
          { required: true, message: '请输入客户简称', trigger: 'blur' }
        ],
        userName: [
          { required: true, message: '请输入手机号码', trigger: 'blur' }
        ],
        // address: [
        //   { required: true, validator: newRule, trigger: ['blur']}
        // ],
        creditCode: [
          { required: false, validator: creditCode, trigger: 'blur' }
        ],
        
      }
    }
  },
  created () {
    this.config({
      api: '/business/clientManger',
      'field.id': 'id'
    })
  },
  methods: {
    open (title, target) {
      this.title = title
      this.visible = true
      // this.form.fileList = []
      // this.form.changeFileList = []
      // 编辑
      // debugger
      this.$nextTick(() => {
        this.$refs.form.clearValidate()
        this.$refs.form.resetFields()
        const dingdingInfo = target.dingdingInfo ? JSON.parse(target.dingdingInfo) : {}
        // debugger
        for (const key in this.form) {
          this.form[key] = dingdingInfo[key]
        }
        this.form.id = target.id
        // this.form.fileList = JSON.parse(JSON.stringify(target.fileList)) || []
        // this.form.fileList.forEach(item => item.url = item.fileurlfull)
        console.log(this.form);
      })
    },
    begin() {
      this.isUploading=true
    },
    end() {
      this.isUploading=false
    },
    confirm() {
      this.$refs.form.validate((valid) => {
        if (!valid) {
          return
        }
        this.isWorking = true
        update({
          id: this.form.id,
          dingdingInfo: JSON.stringify(this.form)
        })
          .then(() => {
            this.visible = false
            this.$refs.form.resetFields()
            this.$message.success('修改成功')
            this.$emit('success')
          })
          .catch(e => {
            this.$message.error(e)
          })
          .finally(() => {
            this.isWorking = false
          })
      })
    }
  },
}
</script>
 
<style lang="scss" scoped>
.tips-style {
  background-color: #f7f7f7;
  height: 30px;
  line-height: 30px;
  a {
    text-decoration:none
  }
}
.item-line {
  ::v-deep .el-form-item__content {
    width: 480px;
  }
}
.short-line {
  // ::v-deep .el-form-item__content {
  //   width: 686px;
  //   display: flex;
  //   .el-input--small {
  //     width: 286px!important;
  //     margin-right: 10px;
  //   }
  //   // width: 680px;
  // }
  ::v-deep .el-form-item {
    display: flex;
  }
  ::v-deep .el-form-item__content {
    display: flex;
    .el-input--small {
      width: 286px!important;
      margin-right: 10px;
    }
    width: 680px;
  }
  
}
.pic-line {
  ::v-deep .el-form-item__content {
    width: 500px;
  }
}
.address {
  display: flex;
  .line {
    width: 10px;
  }
}
.sub-title {
  font-size: 20px;
  font-weight: 600;
  margin-top: 10px;
  margin-bottom: 10px;
}
 
</style>