Blame view

src/views/jkfw/ptjk/components/addDialog.vue 6.87 KB
1
<!--
yuanbo committed
2
 * @Description:
3 4 5
 * @Autor: renchao
 * @LastEditTime: 2023-07-19 09:50:23
-->
蔡俊立 committed
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
<template>
  <dialogBox :title="editFlag ? '编辑接口信息' : '新增接口信息'" @submitForm="submitForm" saveButton="保存" width="50%" :isFullscreen="false"
    @closeDialog="closeDialog" v-model="value">
    <div>
      <el-form ref="ruleForm" :model="ruleForm" label-width="100px" :rules="rules">
        <el-row>
          <el-col :span="12">
            <el-form-item label="接口代码:" prop="interfaceCode">
              <el-input v-model="ruleForm.interfaceCode" :disabled="editFlag"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="接口名称:" prop="interfaceService">
              <el-input v-model="ruleForm.interfaceService"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="接口地址:" prop="interfaceApi">
              <el-input v-model="ruleForm.interfaceApi"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="接口方式:" prop="interfaceMethod">
              <el-select v-model="ruleForm.interfaceMethod" class="width100" placeholder="请选择">
34
                <el-option v-for="item in interfaceMethods" :key="item" :label="item" :value="item"></el-option>
蔡俊立 committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="接口类型:" prop="interfaceType">
              <el-select v-model="ruleForm.interfaceType" class="width100" placeholder="请选择">
                <el-option v-for="item in interfaceTypes" :key="item.value" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="接口密钥:" prop="interfaceKey">
              <el-input v-model="ruleForm.interfaceKey"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
赵千 committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
          <el-col :span="12">
            <el-form-item label="接口类型:" prop="requestType">
              <el-input v-model="ruleForm.requestType"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="接口模块:" prop="requestModule">
              <el-input v-model="ruleForm.requestModule"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="接口参数:" prop="requestParams">
              <el-input v-model="ruleForm.requestParams" type="textarea" :rows="4"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
蔡俊立 committed
73 74 75 76 77 78 79 80 81 82 83 84
          <el-col :span="24">
            <el-form-item label="接口描述:" prop="interfaceDescription">
              <el-input v-model="ruleForm.interfaceDescription" type="textarea" :rows="4"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
  </dialogBox>
</template>

<script>
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
  import { addSysInterface, editSysInterface } from "@/api/ptjk.js"
  export default {
    components: {
    },
    computed: {
    },
    props: {
      value: { type: Boolean, default: false },
      editFlag: { type: Boolean, default: false }
    },
    data () {
      return {
        //表单提交数据
        interfaceMethods: ['webapi', 'webservice'],
        interfaceTypes: [
          { 'label': '工作流服务平台', 'value': '1' },
          { 'label': '权限平台', 'value': '2' },
          { 'label': '定时器服务', 'value': '3' },
          { 'label': '其他第三方平台', 'value': '4' },
蔡俊立 committed
104
        ],
105 106 107 108 109 110 111 112
        ruleForm: {
          interfaceCode: '',
          interfaceService: '',
          interfaceDescription: '',
          interfaceApi: '',
          interfaceMethod: '',
          interfaceType: '',
          interfaceKey: '',
赵千 committed
113 114 115
          requestParams: '',
          requestType: '',
          requestModule: '',
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
        },
        rules: {
          interfaceCode: [
            { required: true, message: '接口代码不能为空', trigger: 'blur' }
          ],
          interfaceService: [
            { required: true, message: '接口服务名称不能为空', trigger: 'blur' }
          ],
          interfaceApi: [
            { required: true, message: '接口api地址不能为空', trigger: 'blur' }
          ],
          interfaceMethod: [
            { required: true, message: '接口方式不能为空', trigger: 'change' }
          ],
          interfaceType: [
            { required: true, message: '入库编号不能为空', trigger: 'change' }
          ],
        },
      }
蔡俊立 committed
135
    },
136 137
    methods: {
      //表单提交
yuanbo committed
138 139 140 141
      /**
       * @description: 表单提交
       * @author: renchao
       */
142 143 144 145 146 147 148 149
      submitForm () {
        let that = this;
        that.$refs.ruleForm.validate(valid => {
          if (valid) {
            if (this.editFlag) {
              this.editInterface();
            } else {
              this.addInterface();
蔡俊立 committed
150
            }
151 152 153 154 155 156 157
          } else {
            // console.log('error submit!!');
            return false;
          }
        });
      },
      //新增接口
yuanbo committed
158 159 160 161
      /**
       * @description: 新增接口
       * @author: renchao
       */
162 163 164 165 166 167 168 169 170
      addInterface () {
        addSysInterface(this.ruleForm).then(res => {
          if (res.code == 200) {
            this.$message.success("保存成功");
            this.closeDialog();
            this.$parent.queryClick();
          } else {
            this.$message.error(res.message)
          }
蔡俊立 committed
171
        })
172 173
      },
      //编辑接口
yuanbo committed
174 175 176 177
      /**
       * @description: 编辑接口
       * @author: renchao
       */
178
      editInterface () {
蔡俊立 committed
179
        editSysInterface(this.ruleForm).then(res => {
180 181 182 183 184 185 186
          if (res.code == 200) {
            this.$message.success("编辑成功");
            this.closeDialog();
            this.$parent.queryClick();
          } else {
            this.$message.error(res.message)
          }
蔡俊立 committed
187
        })
188 189
      },
      //获取详情
yuanbo committed
190 191 192 193 194
      /**
       * @description: 获取详情
       * @param {*} item
       * @author: renchao
       */
195 196 197 198
      getDetailInfo (item) {
        this.ruleForm = item
      },
      //关闭弹窗
yuanbo committed
199 200 201 202
      /**
       * @description: 关闭弹窗
       * @author: renchao
       */
203 204 205 206 207 208 209 210 211 212 213
      closeDialog () {
        this.$emit("input", false);
        this.ruleForm = {
          interfaceCode: '',
          interfaceService: '',
          interfaceDescription: '',
          interfaceApi: '',
          interfaceMethod: '',
          interfaceType: '',
          interfaceKey: '',
        }
蔡俊立 committed
214 215 216 217 218
      }
    }
  }
</script>
<style scoped lang="scss">
219
  @import "~@/styles/mixin.scss";
蔡俊立 committed
220
</style>