Browse Source

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

liuyang 2 years ago
parent
commit
490ca8bb4d

+ 7 - 0
src/api/flow.ts

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
 * 版本 start
92
 * 版本 start
86
 */
93
 */

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

8
        :style="{ width: '260px' }"
8
        :style="{ width: '260px' }"
9
        :props-map="{ label: 'version', value: 'id' }"
9
        :props-map="{ label: 'version', value: 'id' }"
10
        :options="versionList"
10
        :options="versionList"
11
        @change="changeVersion"
11
      ></common-select>
12
      ></common-select>
12
      <div class="btns">
13
      <div class="btns">
13
        <template v-for="btn in btns" :key="btn.name">
14
        <template v-for="btn in btns" :key="btn.name">
14
          <el-button
15
          <el-button
15
            size="small"
16
            size="small"
16
            class="btn"
17
            class="btn"
18
            :disabled="btn.disabled"
17
            :type="btn.type"
19
            :type="btn.type"
18
            @click.stop="btn.onClick"
20
            @click.stop="btn.onClick"
19
          >
21
          >
39
      </template>
41
      </template>
40
      <template #right>
42
      <template #right>
41
        <div class="service-content">
43
        <div class="service-content">
44
          <!-- 详情 -->
42
          <api-detail-page
45
          <api-detail-page
43
            v-if="apiDetail"
46
            v-if="apiDetail"
44
            :api-detail="apiDetail"
47
            :api-detail="apiDetail"
45
            :version-state="versionState.CURRENT_STATE"
48
            :version-state="versionState"
46
            @edit-logic-api="editLogicApi"
49
            @edit-logic-api="editLogicApi"
47
            @init-api-info="initApiInfo"
50
            @init-api-info="initApiInfo"
48
          ></api-detail-page>
51
          ></api-detail-page>
83
import { formConfig } from './_config';
86
import { formConfig } from './_config';
84
import ApiDetailPage from './_components/ApiDetailPage.vue';
87
import ApiDetailPage from './_components/ApiDetailPage.vue';
85
import * as api from '../../api/flow';
88
import * as api from '../../api/flow';
89
import { VERSION_STATE, LOGIC_STATE } from './enum.js';
86
90
87
const { proxy } = getCurrentInstance();
91
const { proxy } = getCurrentInstance();
88
const router = useRouter();
92
const router = useRouter();
91
const drawerType = ref('module');
95
const drawerType = ref('module');
92
const operateType = ref('create');
96
const operateType = ref('create');
93
const apiDetail = ref(null);
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
function publishVersion() {}
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
const systemInfo = ref(null);
140
const systemInfo = ref(null);
113
async function getSystemDetail() {
141
async function getSystemDetail() {
114
  await api.getSystemDetailById(systemId.value).then((res) => {
142
  await api.getSystemDetailById(systemId.value).then((res) => {
115
    if (res.resultCode === '0') {
143
    if (res.resultCode === '0') {
116
      systemInfo.value = res.result;
144
      systemInfo.value = res.result;
117
      curVersionId.value = systemInfo.value.version.id;
145
      curVersionId.value = systemInfo.value.version.id;
146
      versionState.value = systemInfo.value.version.state;
118
    } else {
147
    } else {
119
      systemInfo.value = null;
148
      systemInfo.value = null;
120
    }
149
    }
142
      console.log(err);
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
 * 版本 end
188
 * 版本 end
147
 */
189
 */
222
    pageNumber: 1,
264
    pageNumber: 1,
223
    versionId: curVersionId.value
265
    versionId: curVersionId.value
224
  };
266
  };
267
  curLogic.value = '';
225
  api.getModuleList(params).then((res) => {
268
  api.getModuleList(params).then((res) => {
226
    if (res.resultCode === '0') {
269
    if (res.resultCode === '0') {
227
      moduleTreeData.value = res.result;
270
      moduleTreeData.value = res.result;
549
// 测试
592
// 测试
550
function initApiInfo() {}
593
function initApiInfo() {}
551
594
552
watch(curLogic.value, () => {
595
watch(curLogic, () => {
553
  getApiDetail();
596
  getApiDetail();
554
});
597
});
555
// watch 监听
598
// watch 监听

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

14
            DELETED("5", "废弃");
14
            DELETED("5", "废弃");
15
          -->
15
          -->
16
          <el-button
16
          <el-button
17
            :disabled="props.versionState === '0'"
17
            :disabled="props.versionState === 'PUBLISHED'"
18
            @click.stop="stopTest"
18
            @click.stop="stopTest"
19
          >
19
          >
20
            测试
20
            测试
21
          </el-button>
21
          </el-button>
22
          <el-button
22
          <el-button
23
            :disabled="
23
            :disabled="
24
              apiDetail?.state !== 'STARTED' || props.versionState === '0'
24
              apiDetail?.state !== 'STARTED' ||
25
              props.versionState === 'PUBLISHED'
25
            "
26
            "
26
            @click.stop="stopLogic"
27
            @click.stop="stopLogic"
27
          >
28
          >
28
            停用
29
            停用
29
          </el-button>
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
          </el-button>
40
          </el-button>
33
        </div>
41
        </div>
323
331
324
const { testRequest, test, updateTestData } = testHooks();
332
const { testRequest, test, updateTestData } = testHooks();
325
function validate() {}
333
function validate() {}
334
335
function handleClick() {}
326
watch(
336
watch(
327
  props,
337
  props,
328
  () => {
338
  () => {

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