| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <template>
- <div v-loading="loading">
- <div class="white-box">
- <el-form ref="form" :model="form" label-width="250px" class="form-page">
- <el-form-item label="接口类型">{{apiType}}</el-form-item>
- <template v-for="item in configData">
- <el-form-item :label="item.TITLE" :key="item.CONFIG_NAME">
- <template v-if="item.INPUT_TYPE==='2'">
- <el-select v-model="item.VALUE" placeholder="请选择">
- <el-option v-for="optionItem in item.OPTIONS" :label="optionItem.label" :value="optionItem.value"
- :key="optionItem.label"></el-option>
- </el-select>
- </template>
- <template v-else-if="item.INPUT_TYPE==='3'">
- <el-checkbox-group v-model="item.VALUE">
- <el-checkbox v-for="optionItem in item.OPTIONS" :label="optionItem.label" :value="optionItem.value"
- :key="optionItem.label"></el-checkbox>
- </el-checkbox-group>
- </template>
- <template v-else-if="item.INPUT_TYPE==='4'">
- <el-date-picker v-model="item.VALUE" type="year" placeholder="选择年">
- </el-date-picker>
- </template>
- <template v-else-if="item.INPUT_TYPE==='5'">
- <el-date-picker
- v-model="item.VALUE"
- type="datetime"
- placeholder="Select date">
- </el-date-picker>
- </template>
- <template v-else-if="item.INPUT_TYPE==='6'">
- <el-date-picker
- v-model="item.VALUE"
- type="date"
- placeholder="Select date">
- </el-date-picker>
- </template>
- <template v-else-if="item.INPUT_TYPE==='7'">
- <el-time-select v-model="item.VALUE"
- :picker-options="{start: item.OPTIONS.start, end: item.OPTIONS.end, step: item.OPTIONS.step}"
- placeholder="选择时间">
- </el-time-select>
- </template>
- <template v-else-if="item.INPUT_TYPE==='8'">
- <el-switch v-model="item.VALUE">
- </el-switch>
- </template>
- <template v-else>
- <el-input v-model="item.VALUE" placeholder="请输入内容">
- <template v-if="!!item.UNIT" slot="append">{{item.UNIT}}</template>
- </el-input>
- </template>
- </el-form-item>
- </template>
- <el-form-item>
- <el-button type="primary" @click="onSubmit" :loading="submitButtonStat">更新</el-button>
- </el-form-item>
- </el-form>
- </div>
- </div>
- </template>
- <script>
- import network from './../../utils/network'
- export default {
- name: 'config_api-edit',
- mounted () {
- this.getData()
- },
- data () {
- return {
- loading: true,
- submitButtonStat: false,
- configData: null,
- apiType: '',
- }
- },
- computed: {
- form: function () {
- let result = {}
- for (let i in this.configData) {
- result[i] = this.configData[i].VALUE
- }
- return result
- }
- },
- methods: {
- onSubmit () {
- this.submitButtonStat = true
- let requestPath = ``
- if(this.$route.params.type === 'ocr'){
- requestPath = `config/ocr-api-edit/${this.$route.params.id}`
- } else if(this.$route.params.type === 'sms') {
- requestPath = `config/sms-api-edit/${this.$route.params.id}`
- }
- network.postData(requestPath, {config: this.form}).then(response => {
- this.$message({
- message: response,
- type: 'success'
- })
- this.submitButtonStat = false
- this.getData()
- this.$router.go(-1)
- }).catch(response => {
- this.submitButtonStat = false
- this.getData()
- })
- },
- getData () {
- if(this.$route.params.type === 'ocr'){
- network.getData(`config/ocr-api-edit/${this.$route.params.id}`).then(response => {
- this.configData = response.CONFIGS
- this.apiType = response.apiType
- this.loading = false
- })
- } else if(this.$route.params.type === 'sms') {
- network.getData(`config/sms-api-edit/${this.$route.params.id}`).then(response => {
- this.configData = response.CONFIGS
- this.apiType = response.apiType
- this.loading = false
- })
- } else {
- this.loading = false
- }
- },
- }
- }
- </script>
- <style scoped>
- </style>
|