Selaa lähdekoodia

update: 完成版本切换按钮状态控制

liuyang 2 vuotta sitten
vanhempi
commit
490ca8bb4d

+ 7 - 0
src/api/flow.ts

@ -81,6 +81,13 @@ export function changeVersionById(data: any, id: any) {
81 81
  });
82 82
}
83 83
84
// 点击编辑切换或者生成dev版本
85
export function changeVersionToEdit(id: any) {
86
  return AIotRequest.post({
87
    url: `${flow.systemEditMgmt}/${id}`
88
  });
89
}
90
84 91
/**
85 92
 * 版本 start
86 93
 */

+ 57 - 14
src/views/flow/SystemDetail.vue

@ -8,12 +8,14 @@
8 8
        :style="{ width: '260px' }"
9 9
        :props-map="{ label: 'version', value: 'id' }"
10 10
        :options="versionList"
11
        @change="changeVersion"
11 12
      ></common-select>
12 13
      <div class="btns">
13 14
        <template v-for="btn in btns" :key="btn.name">
14 15
          <el-button
15 16
            size="small"
16 17
            class="btn"
18
            :disabled="btn.disabled"
17 19
            :type="btn.type"
18 20
            @click.stop="btn.onClick"
19 21
          >
@ -39,10 +41,11 @@
39 41
      </template>
40 42
      <template #right>
41 43
        <div class="service-content">
44
          <!-- 详情 -->
42 45
          <api-detail-page
43 46
            v-if="apiDetail"
44 47
            :api-detail="apiDetail"
45
            :version-state="versionState.CURRENT_STATE"
48
            :version-state="versionState"
46 49
            @edit-logic-api="editLogicApi"
47 50
            @init-api-info="initApiInfo"
48 51
          ></api-detail-page>
@ -83,6 +86,7 @@ import { useRoute, useRouter } from 'vue-router';
83 86
import { formConfig } from './_config';
84 87
import ApiDetailPage from './_components/ApiDetailPage.vue';
85 88
import * as api from '../../api/flow';
89
import { VERSION_STATE, LOGIC_STATE } from './enum.js';
86 90
87 91
const { proxy } = getCurrentInstance();
88 92
const router = useRouter();
@ -91,30 +95,55 @@ const showDrawer = ref(false);
91 95
const drawerType = ref('module');
92 96
const operateType = ref('create');
93 97
const apiDetail = ref(null);
98
const versionState = ref('');
94 99
100
const systemId = computed(() => route.query.id);
101
const curVersionId = ref('');
102
103
console.log(VERSION_STATE, LOGIC_STATE);
95 104
// 编辑版本
96
function editVersion() {}
105
function editVersion() {
106
  api.changeVersionToEdit(curVersionId.value).then((res) => {
107
    if (res.resultCode === '0') {
108
      versionState.value = 'EDITED';
109
      curVersionId.value = res.result;
110
      proxy.$message.info('开始编辑');
111
      // eslint-disable-next-line no-use-before-define
112
      getModuleData();
113
    } else {
114
      proxy.$message.error(res.resultMsg);
115
    }
116
  });
117
}
97 118
// 发布版本
98 119
function publishVersion() {}
99
const btns = ref([
100
  { label: '编辑', name: 'edit', onClick: editVersion, type: 'primary' },
101
  { label: '发布', name: 'publish', onClick: publishVersion, type: 'primary' }
102
]);
103
104
const versionState = ref({
105
  EDIT_STATE: '0', // 稳定太
106
  DEVELOPMENT_STATE: '1', // 编辑太
107
  CURRENT_STATE: '0' // 当前默认状态为稳定太
120
const btns = computed(() => {
121
  return [
122
    {
123
      label: '编辑',
124
      name: 'edit',
125
      disabled: versionState.value === 'EDITED',
126
      onClick: editVersion,
127
      type: 'primary'
128
    },
129
    {
130
      label: '发布',
131
      name: 'publish',
132
      disabled: versionState.value === 'PUBLISHED',
133
      onClick: publishVersion,
134
      type: 'primary'
135
    }
136
  ];
108 137
});
138
109 139
// 获取系统详情
110
const systemId = computed(() => route.query.id);
111
const curVersionId = ref('');
112 140
const systemInfo = ref(null);
113 141
async function getSystemDetail() {
114 142
  await api.getSystemDetailById(systemId.value).then((res) => {
115 143
    if (res.resultCode === '0') {
116 144
      systemInfo.value = res.result;
117 145
      curVersionId.value = systemInfo.value.version.id;
146
      versionState.value = systemInfo.value.version.state;
118 147
    } else {
119 148
      systemInfo.value = null;
120 149
    }
@ -142,6 +171,19 @@ function getVersionList() {
142 171
      console.log(err);
143 172
    });
144 173
}
174
175
// 切换版本
176
function changeVersion(val) {
177
  console.log(val);
178
  curVersionId.value = val;
179
  versionList.value.forEach((item) => {
180
    if (item.id === val) {
181
      versionState.value = item.state;
182
    }
183
  });
184
  // eslint-disable-next-line no-use-before-define
185
  getModuleData();
186
}
145 187
/**
146 188
 * 版本 end
147 189
 */
@ -222,6 +264,7 @@ function getModuleData() {
222 264
    pageNumber: 1,
223 265
    versionId: curVersionId.value
224 266
  };
267
  curLogic.value = '';
225 268
  api.getModuleList(params).then((res) => {
226 269
    if (res.resultCode === '0') {
227 270
      moduleTreeData.value = res.result;
@ -549,7 +592,7 @@ function editLogicApi() {
549 592
// 测试
550 593
function initApiInfo() {}
551 594
552
watch(curLogic.value, () => {
595
watch(curLogic, () => {
553 596
  getApiDetail();
554 597
});
555 598
// watch 监听

+ 13 - 3
src/views/flow/_components/ApiDetailPage.vue

@ -14,20 +14,28 @@
14 14
            DELETED("5", "废弃");
15 15
          -->
16 16
          <el-button
17
            :disabled="props.versionState === '0'"
17
            :disabled="props.versionState === 'PUBLISHED'"
18 18
            @click.stop="stopTest"
19 19
          >
20 20
            测试
21 21
          </el-button>
22 22
          <el-button
23 23
            :disabled="
24
              apiDetail?.state !== 'STARTED' || props.versionState === '0'
24
              apiDetail?.state !== 'STARTED' ||
25
              props.versionState === 'PUBLISHED'
25 26
            "
26 27
            @click.stop="stopLogic"
27 28
          >
28 29
            停用
29 30
          </el-button>
30
          <el-button type="success" @click.stop="editLogicApi">
31
          <el-button
32
            type="success"
33
            :disabled="
34
              apiDetail?.state === 'STARTED' ||
35
              props.versionState === 'PUBLISHED'
36
            "
37
            @click.stop="editLogicApi"
38
          >
31 39
            编辑逻辑流
32 40
          </el-button>
33 41
        </div>
@ -323,6 +331,8 @@ function testHooks() {
323 331
324 332
const { testRequest, test, updateTestData } = testHooks();
325 333
function validate() {}
334
335
function handleClick() {}
326 336
watch(
327 337
  props,
328 338
  () => {

+ 0 - 0
src/views/flow/_hooks/flowHooks.js