SiteProcess.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <a-drawer :title="title" placement="right" :closable="true" v-model:open="props.visible" @close="onClose" destroyOnClose :width="600">
  3. <a-steps :current="current" direction="vertical" class="self_step">
  4. <a-step v-for="(item, index) in stepData" :key="index">
  5. <template #title>
  6. <div v-if="item.status == 1" style="width: 100%; line-height: 21px">
  7. <span>{{ item.title }}</span>
  8. <a-button style="margin-left: 16px" ghost v-if="index > 0" type="primary" size="small" @click="finishOrRollbackStep(item, index)">
  9. 撤销
  10. </a-button>
  11. </div>
  12. <div style="width: 100%; line-height: 21px" v-else-if="index === current">
  13. <span :style="{ color: 'blue' }">{{ item.title }}</span>
  14. <a-button
  15. style="margin-left: 16px"
  16. v-if="showFinBtn && !isCustomer"
  17. ghost
  18. type="primary"
  19. size="small"
  20. @click="finishOrRollbackStep(item, index)"
  21. >
  22. 完成
  23. </a-button>
  24. </div>
  25. <div style="width: 100%; line-height: 21px" v-else>
  26. <span :style="{ color: '#606266' }">{{ item.title }}</span>
  27. <a-button
  28. :style="{ marginLeft: '16px', color: '#606266' }"
  29. style=""
  30. v-if="showFinBtn && !isCustomer"
  31. ghost
  32. type="primary"
  33. size="small"
  34. @click="finishOrRollbackStep(item, index)"
  35. >完成</a-button
  36. >
  37. </div>
  38. </template>
  39. <template #description>
  40. <div style="margin: 2.5px 0" v-if="item.title !== null">{{ item.description }}</div>
  41. </template>
  42. </a-step>
  43. </a-steps>
  44. </a-drawer>
  45. </template>
  46. <script lang="ts" setup name="seoProcess">
  47. import '/@/assets/less/common.less';
  48. import { getAction, postActionForm } from '/@/api/manage/manage';
  49. import { reactive, ref } from 'vue';
  50. import { useMessage } from '@/hooks/web/useMessage';
  51. const { createMessage } = useMessage();
  52. const url = ref('');
  53. const current = ref(0);
  54. let stepData = ref([{ value: '', title: '', color: '', description: '', status: 0 }]);
  55. let record = reactive({
  56. code: undefined,
  57. siteFlowStatus: '',
  58. });
  59. const showFinBtn = ref(false);
  60. const isCustomer = ref(false);
  61. const props = defineProps({
  62. visible: {
  63. type: Boolean,
  64. default: false,
  65. },
  66. title: {
  67. type: String,
  68. default: 'SEO流程',
  69. },
  70. });
  71. const emit = defineEmits(['ok', 'close', 'reload']);
  72. function init(r, t) {
  73. record = r;
  74. if (t == 'seo') {
  75. url.value = '/adweb/executeNode/querySEOFlow?siteCode=' + r.code + '&historyId=' + r.historyId;
  76. } else {
  77. url.value = '/sys/dict/getDictItems/build_website_status';
  78. }
  79. showStep();
  80. }
  81. function onClose() {
  82. emit('close');
  83. closeStep();
  84. }
  85. function showStep() {
  86. stepData.value = [];
  87. getAction(url.value, null)
  88. .then((res) => {
  89. if (res.code === 0) {
  90. stepData.value = res.result;
  91. // 当前步骤
  92. for (let i = 0; i < res.result.length; i++) {
  93. if (res.result[i].value == record.siteFlowStatus) {
  94. current.value = i + 1;
  95. showFinBtn.value = true;
  96. }
  97. if (res.result[i].value <= record.siteFlowStatus) {
  98. stepData.value[i].status = 1;
  99. } else {
  100. stepData.value[i].status = 0;
  101. }
  102. }
  103. if (current.value == 0) {
  104. current.value = res.result.length;
  105. showFinBtn.value = false;
  106. }
  107. }
  108. })
  109. .catch((e) => {
  110. createMessage.warning('获取数据失败!' + e.message());
  111. });
  112. }
  113. function closeStep() {
  114. showFinBtn.value = false;
  115. current.value = 0;
  116. stepData.value = [];
  117. }
  118. function finishOrRollbackStep(item, index) {
  119. let params;
  120. if (item.status === 0) {
  121. params = {
  122. stepFlowId: item.value,
  123. siteCode: record.code,
  124. currentStep: item.label,
  125. };
  126. current.value++;
  127. stepData.value[index].status = 1;
  128. } else {
  129. let currentItem = stepData.value[index - 1];
  130. params = {
  131. stepFlowId: currentItem.value,
  132. siteCode: record.code,
  133. currentStep: currentItem.label,
  134. };
  135. current.value--;
  136. stepData.value[index].status = 0;
  137. }
  138. postActionForm('/adweb/adwebSite/finishOrRollbackStep', params, 120000).then((res) => {
  139. if (res.code === 200) {
  140. createMessage.success('操作成功!');
  141. // showStep();
  142. emit('reload');
  143. }
  144. });
  145. }
  146. defineExpose({ init });
  147. </script>
  148. <style lang="less" scoped>
  149. .self_step {
  150. /deep/ .ant-steps-item-content {
  151. width: 410px;
  152. .ant-steps-item-title {
  153. width: 100%;
  154. span {
  155. font-size: 13px;
  156. color: green;
  157. &.fr {
  158. float: right;
  159. }
  160. }
  161. }
  162. .ant-steps-item-description {
  163. div {
  164. padding-left: 20px;
  165. font-size: 14px;
  166. }
  167. }
  168. }
  169. }
  170. .doBtn {
  171. position: absolute;
  172. bottom: 15px;
  173. width: 150px;
  174. right: 150px;
  175. }
  176. </style>
  177. <style lang="less">
  178. .self_step {
  179. .ant-steps-item-finish .ant-steps-item-icon > .ant-steps-icon .ant-steps-icon-dot {
  180. background: green;
  181. }
  182. }
  183. </style>