| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- <template>
- <el-form :model="serviceParamForm" ref="serviceParamForm">
- <table id="serviceParamTable">
- <colgroup>
- <col width="6%" align="center" valign="middle"/>
- <col width="20%" align="center" valign="middle"/>
- <col width="20%" align="center" valign="middle"/>
- <col width="20%" align="center" valign="middle"/>
- <col width="20%" align="center" valign="middle"/>
- <col width="14%" align="center" valign="middle"/>
- </colgroup>
- <thead>
- <tr>
- <th>序号</th>
- <th>参数字段</th>
- <th>参数名称</th>
- <th>参数类型</th>
- <th>参数备注</th>
- <th>操作</th>
- </tr>
- </thead>
- <tbody>
- <tr v-for="(param, index) in serviceParamForm.params" :key="index">
- <td>
- {{ index + 1 }}
- </td>
- <td>
- <el-form-item
- :prop="'params.' + index + '.paramCode'"
- :rules="{
- required: true,
- message: '参数字段不能为空',
- trigger: 'blur',
- }"
- >
- <el-input v-model="param.paramCode"></el-input>
- </el-form-item>
- </td>
- <td>
- <el-form-item
- :prop="'params.' + index + '.paramName'"
- :rules="{
- required: true,
- message: '参数名称不能为空',
- trigger: 'blur',
- }"
- >
- <el-input v-model="param.paramName"></el-input>
- </el-form-item>
- </td>
- <td>
- <el-form-item
- :prop="'params.' + index + '.paramType'"
- :rules="{
- required: true,
- message: '参数类型不能为空',
- trigger: 'blur',
- }"
- >
- <el-select v-model="param.paramType" placeholder="请选择">
- <el-option
- v-for="item in paramTypes"
- :key="item"
- :label="item"
- :value="item"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </td>
- <td>
- <el-form-item>
- <el-input v-model="param.paramNote"></el-input>
- </el-form-item>
- </td>
- <td>
- <el-button @click.prevent="removeParam(param)"> 删除</el-button>
- </td>
- </tr>
- </tbody>
- </table>
- <el-row type="flex" justify="center">
- <el-button
- icon="ArrowLeft"
- @click="forwardStep"
- circle
- ></el-button>
- <el-button @click="addParam">新增参数</el-button>
- <el-button type="primary" @click="submitForm('serviceParamForm')">
- 保存
- </el-button>
- <el-button @click="exit">退出</el-button>
- <el-button icon="ArrowRight" @click="nextStep" circle></el-button>
- </el-row>
- </el-form>
- </template>
- <script>
- import {addServiceParam, delServiceParam, getServiceAllParam,} from "@/api/service/info";
- export default {
- props: ["srvId"],
- data() {
- return {
- serviceParamForm: {
- params: [
- {
- srvId: this.srvId,
- paramCode: "",
- paramName: "",
- paramType: "string",
- paramNote: "",
- },
- ],
- },
- paramTypes: ["string", "int", "double", "date"],
- };
- },
- methods: {
- // 前进一步
- forwardStep() {
- this.$emit("forwardStep");
- },
- // 后退一步
- nextStep() {
- this.$emit("nextStep");
- },
- // 保存返回值
- submitForm(formName) {
- this.$refs[formName].validate((valid) => {
- if (valid) {
- addServiceParam(this.serviceParamForm.params).then((r) => {
- this.$message({
- message: "添加参数成功",
- type: "success",
- });
- });
- } else {
- return false;
- }
- });
- },
- // 删除行
- removeParam(item) {
- if (item.paramCode) {
- this.$confirm("此操作将永久删除该参数, 是否继续?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }).then(() => {
- delServiceParam({
- srvId: item.srvId,
- paramCode: item.paramCode,
- }).then(() => {
- var index = this.serviceParamForm.params.indexOf(item);
- if (index !== -1) {
- this.serviceParamForm.params.splice(index, 1);
- }
- this.$message({
- type: "success",
- message: "删除成功!",
- });
- });
- });
- } else {
- var index = this.serviceParamForm.params.indexOf(item);
- if (index !== -1) {
- this.serviceParamForm.params.splice(index, 1);
- }
- }
- },
- // 添加参数
- addParam() {
- this.serviceParamForm.params.push({
- srvId: this.srvId,
- paramCode: "",
- paramName: "",
- paramType: "string",
- paramNote: "",
- });
- },
- // 获取参数列表
- getParamList(id) {
- if (id) {
- getServiceAllParam(id).then((r) => {
- if (r.data && r.data.length > 0) {
- this.serviceParamForm.params = r.data;
- } else {
- this.serviceParamForm.params = [
- {
- srvId: this.srvId,
- paramCode: "",
- paramName: "",
- paramType: "string",
- paramNote: "",
- },
- ];
- }
- });
- }
- },
- // 退出
- exit() {
- this.$emit("close");
- },
- },
- watch: {
- srvId: {
- handler(val) {
- this.getParamList(val);
- },
- immediate: true,
- },
- },
- };
- </script>
- <style scoped>
- #serviceParamTable {
- width: 100%;
- margin: 0 auto;
- margin-bottom: 20px;
- border-radius: 5px;
- border: 1px solid #dcdfe6;
- border-collapse: collapse;
- }
- #serviceParamTable th {
- text-align: center;
- vertical-align: middle;
- border-collapse: collapse;
- padding: 5px;
- background-color: #f6f6f6;
- }
- #serviceParamTable td {
- text-align: center;
- vertical-align: middle;
- border-top: 1px solid #dcdfe6;
- border-bottom: 1px solid #dcdfe6;
- border-collapse: collapse;
- padding: 5px;
- }
- #serviceParamTable td :deep(.el-form-item) {
- margin: 0;
- }
- </style>
|