StartPlan.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. <template>
  2. <div class="dialog">
  3. <div class="title gradient-text">启动预案</div>
  4. <div class="close-icon" @click="onClose"></div>
  5. <!-- 响应等级选择和操作按钮 -->
  6. <div class="section-box">
  7. <div class="title2">响应等级</div>
  8. <el-select
  9. v-model="selectedLevel"
  10. placeholder="请选择响应等级"
  11. class="custom-select"
  12. popper-class="custom-select-popper"
  13. :teleported="false"
  14. style="width: 1200px; margin-left: 30px"
  15. @change="change_response_level"
  16. >
  17. <el-option v-for="level in responseLevels" :key="level.value" :label="level.name" :value="level.value"></el-option>
  18. </el-select>
  19. <div class="common-btn-primary2" @click="onStartPlan" v-show="planId === ''">启动预案</div>
  20. <div class="common-btn-primary2" @click="onCancelPlan" v-show="planId != ''">取消响应</div>
  21. <div class="common-btn-primary2" @click="onTaskDelivery" v-show="planId === ''">预案任务下发</div>
  22. </div>
  23. <div class="title-box">{{ planTitle }}</div>
  24. <div class="plan-content">
  25. <!-- 预案内容的标签页 -->
  26. <div class="tabs">
  27. <div v-for="(item, index) in tabs" :key="index" :class="index === activeTab ? 'tab tabActive' : 'tab'" @click="handleClickTab(index)">{{ item.title }}</div>
  28. </div>
  29. <div class="tab-content">
  30. <div class="tabs2">
  31. <div
  32. v-for="(item, index) in tabs[activeTab]?.items"
  33. :key="index"
  34. :class="index === activeTab2 ? 'tab tab-active2' : 'tab'"
  35. @click="handleClickTab2(index)"
  36. >
  37. <div class="text">{{ item.title }}</div>
  38. </div>
  39. </div>
  40. <div class="tab-content2" v-html="tabs[activeTab].items[activeTab2].value" v-if="tabs[activeTab] && tabs[activeTab].items && tabs[activeTab].items[activeTab2]"></div>
  41. <!--
  42. <div class="tab-content2">
  43. {{
  44. tabs[activeTab] && tabs[activeTab].items && tabs[activeTab].items[activeTab2] ? tabs[activeTab].items[activeTab2].value : ''
  45. }}
  46. </div>
  47. -->
  48. </div>
  49. </div>
  50. <TaskDelivery v-model="taskDeliveryState.show" :title="taskDeliveryState.title" :planId="planData.plan_id" :eventId="props.eventId" />
  51. </div>
  52. </template>
  53. <script lang="ts" setup>
  54. import { ref, watch, defineProps, defineEmits, reactive } from 'vue';
  55. import { ElMessage } from 'element-plus';
  56. import TaskDelivery from './TaskDelivery.vue';
  57. import { matchingPlan, launchPlan, getPlanDoc, cancelPlan, updatePlanResponseLevel } from '@/api/duty/eventing';
  58. import { getEventDetail } from '@/api/duty/eventing';
  59. // 内部状态
  60. const planId = ref('');
  61. const planTitle = ref(''); // 预案名称
  62. const selectedLevel = ref(''); // 默认响应等级为空
  63. const response_level = ref('');
  64. // 定义组件接收的属性类型
  65. interface Props {
  66. show: boolean;
  67. eventId: string;
  68. title: string;
  69. }
  70. // 初始化组件属性
  71. const props = defineProps<Props>();
  72. const responseLevels = [
  73. // 响应等级选项
  74. { value: '1', name: '特重大(I级)' },
  75. { value: '2', name: '重大(II级)' },
  76. { value: '3', name: '较大(III级)' },
  77. { value: '4', name: '一般(IV级)' }
  78. ];
  79. const get_response_level_text = (val) => {
  80. return responseLevels.find(item => item.value == val).name
  81. }
  82. const planData = reactive({
  83. //purpose: '',
  84. //basis: '',
  85. //scope: '',
  86. //principles: '',
  87. plan_id: ''
  88. });
  89. // let plan_id = '';
  90. const tabs = ref([
  91. {
  92. title: '总则',
  93. value: '',
  94. items: [
  95. { title: '编制目的', value: '编制目的内容' },
  96. { title: '编制依据', value: '编制依据内容' },
  97. { title: '适用范围', value: '适用范围内容' },
  98. { title: '工作原则', value: '工作原则内容' }
  99. ]
  100. },
  101. { title: '组织体系', items: [] },
  102. { title: '运行机制', items: [] },
  103. { title: '应急保障', items: [] },
  104. { title: '附则', items: [] },
  105. { title: '附件', items: [] }
  106. ]);
  107. const activeTab = ref(0); // 当前激活的标签页
  108. const activeTab2 = ref(0); // 当前激活的标签页
  109. const handleClickTab = (key) => {
  110. activeTab.value = key;
  111. };
  112. const handleClickTab2 = (key) => {
  113. activeTab2.value = key;
  114. };
  115. // 定义事件发射器
  116. const emit = defineEmits(['update:show']);
  117. // 对话框关闭时执行的操作
  118. const onClose = () => {
  119. emit('update:show', false);
  120. };
  121. const change_response_level = async() => {
  122. if(planId.value != "") {
  123. let confirm_msg = "";
  124. if (parseInt(selectedLevel.value) < parseInt(response_level.value)) {
  125. confirm_msg = "是否确认升级预案等级为" + get_response_level_text(selectedLevel.value);
  126. }
  127. else {
  128. confirm_msg = "是否确认降级预案等级为" + get_response_level_text(selectedLevel.value);
  129. }
  130. ElMessageBox.confirm(confirm_msg, '系统提示', {
  131. type: 'warning'
  132. }).then((res) => {
  133. updatePlanResponseLevel({eventId: props.eventId, response_level: selectedLevel.value, plan_id: planData.plan_id})
  134. ElMessage.success("变更预案等级成功");
  135. setTimeout(()=>{onClose()}, 1000);
  136. })
  137. }
  138. console.log(selectedLevel.value);
  139. };
  140. // 处理启动预案的函数
  141. const onStartPlan = async () => {
  142. // 检查是否选择了响应等级
  143. if (!selectedLevel.value) {
  144. ElMessage.error('请先选择响应等级!');
  145. return;
  146. }
  147. // 收集数据
  148. const data = {
  149. response_level: selectedLevel.value,
  150. eventId: props.eventId,
  151. plan_id: planData.plan_id // 确保 planData 中包含正确的 plan_id
  152. };
  153. try {
  154. // 调用后端API启动预案
  155. const response = await launchPlan(data);
  156. if (response && response.code === 200) {
  157. response_level.value = selectedLevel.value;
  158. ElMessage.success('预案启动成功!');
  159. } else if (response && response.code !== 200) {
  160. ElMessage.error(`预案启动失败,后端返回错误码:${response.code}`);
  161. }
  162. } catch (error) {
  163. console.error('启动预案时发生的错误:', error);
  164. if (error.response && error.response.data && error.response.data.message) {
  165. ElMessage.error(error.response.data.message);
  166. } else if (error.response && error.response.status) {
  167. ElMessage.error(`启动预案时发生错误,HTTP 状态码:${error.response.status}`);
  168. } else {
  169. // ElMessage.error('启动预案时发生未知错误,请稍后再试。');
  170. }
  171. }
  172. };
  173. const onCancelPlan = async() => {
  174. ElMessageBox.confirm('是否取消响应?', '系统提示', {
  175. type: 'warning'
  176. }).then((res) => {
  177. cancelPlan({eventId: props.eventId})
  178. ElMessage.success("取消响应成功");
  179. setTimeout(()=>{onClose()}, 1000);
  180. })
  181. }
  182. // 处理标签页点击事件
  183. const onTabClick = (tab: any, event: Event) => {
  184. // 实现标签页点击的逻辑
  185. };
  186. // 控制 taskDelivery 弹窗的显示状态
  187. const taskDeliveryState = reactive({
  188. show: ref(false),
  189. title: '' as string
  190. });
  191. // 处理预案任务下发内容的函数
  192. const onTaskDelivery = () => {
  193. taskDeliveryState.title = '预案任务下发';
  194. taskDeliveryState.show = true;
  195. };
  196. // 调用接口获取预案数据
  197. const fetchPlanData = async () => {
  198. try {
  199. if (!props.eventId) {
  200. ElMessage.warning('eventId 为空,无法获取预案数据');
  201. return;
  202. }
  203. const response = await matchingPlan({ eventId: props.eventId });
  204. if (response && response.code === 200) {
  205. const data = response.data;
  206. planTitle.value = `预案名称: ${data.plan_name}`;
  207. if (data.response_level) {
  208. const isValidLevel = responseLevels.some((level) => level.value === data.response_level);
  209. if (isValidLevel) {
  210. selectedLevel.value = data.response_level;
  211. } else {
  212. ElMessage.error('无效的响应等级,请检查数据');
  213. selectedLevel.value = '';
  214. }
  215. } else {
  216. selectedLevel.value = '';
  217. }
  218. //planData.purpose = data.purpose || '这是内容...';
  219. //planData.basis = data.basis || '这是内容...';
  220. //planData.scope = data.scope || '这是内容...';
  221. //planData.principles = data.principles || '这是内容...';
  222. planData.plan_id = data.plan_id; // 确保 planData 中包含 plan_id
  223. getPlanDocInfo(planData.plan_id);
  224. } else {
  225. ElMessage.error('未能从服务器获取有效的预案数据');
  226. }
  227. } catch (error) {
  228. console.log('error:', error);
  229. ElMessage.error('获取预案数据失败');
  230. }
  231. };
  232. const getPlanDocInfo = (plan_id) => {
  233. getPlanDoc({plan_id: plan_id}).then((res)=> {
  234. if(res.code === 200) {
  235. tabs.value = res.data;
  236. }
  237. });
  238. }
  239. // 在组件挂载时尝试获取预案数据
  240. onMounted(async() => {
  241. if (props.eventId) {
  242. const response = await getEventDetail({ event_id: props.eventId });
  243. const event_data = response.data;
  244. planId.value = event_data.plan_id;
  245. fetchPlanData();
  246. }
  247. });
  248. // 监听 eventId 变化
  249. watch(
  250. () => props.eventId,
  251. (newEventId) => {
  252. if (newEventId) {
  253. fetchPlanData();
  254. }
  255. }
  256. );
  257. </script>
  258. <style scoped>
  259. .dialog {
  260. position: absolute;
  261. top: 478px;
  262. left: 50%;
  263. transform: translateX(-50%);
  264. width: 2839px;
  265. height: 1263px;
  266. background: url('@/assets/images/plan/dialog.png') no-repeat;
  267. padding-top: 200px;
  268. color: #fff;
  269. font-size: 36px;
  270. .title {
  271. position: absolute;
  272. top: 30px;
  273. left: 55px;
  274. font-size: 80px;
  275. }
  276. .close-icon {
  277. position: absolute;
  278. top: 0px;
  279. right: 0px;
  280. width: 75px;
  281. height: 70px;
  282. background: url('@/assets/images/map/rightMenu/close.png') no-repeat;
  283. background-size: 100% 100%;
  284. cursor: pointer;
  285. }
  286. .section-box {
  287. display: flex;
  288. align-items: center;
  289. padding: 15px 60px;
  290. border-bottom: 6px solid rgba(50, 132, 251, 0.4);
  291. .common-btn-primary2 {
  292. margin-left: 40px;
  293. }
  294. }
  295. .title-box {
  296. background-image: url('@/assets/images/plan/titleBox.png');
  297. background-repeat: no-repeat;
  298. background-size: 354px 28px;
  299. background-position: bottom left;
  300. margin: 40px 60px 0;
  301. font-family: 'YouSheBiaoTiHei';
  302. font-size: 56px;
  303. padding-left: 50px;
  304. }
  305. }
  306. h2 {
  307. text-align: center;
  308. }
  309. /* 样式 */
  310. .plan-content {
  311. display: flex;
  312. flex-direction: column;
  313. margin: 40px 60px;
  314. }
  315. .button-container {
  316. display: flex;
  317. justify-content: flex-end;
  318. }
  319. .content-row {
  320. margin-top: 20px;
  321. }
  322. .tabs {
  323. display: flex;
  324. width: 100%;
  325. overflow-x: auto;
  326. .tab {
  327. width: 350px;
  328. min-height: 78px;
  329. background: url('@/assets/images/plan/tab.png') no-repeat;
  330. background-size: 350px 78px;
  331. background-position: bottom;
  332. display: flex;
  333. justify-content: center;
  334. align-items: flex-end;
  335. margin-left: 50px;
  336. font-family: 'YouSheBiaoTiHei';
  337. font-size: 38px;
  338. cursor: pointer;
  339. padding: 0 35px;
  340. text-align: center;
  341. &:hover {
  342. background: url('@/assets/images/plan/tabActive.png') no-repeat;
  343. background-position: bottom;
  344. }
  345. &:first-child {
  346. margin-left: 0;
  347. }
  348. }
  349. .tabActive {
  350. background: url('@/assets/images/plan/tabActive.png') no-repeat;
  351. background-position: bottom;
  352. }
  353. }
  354. .tab-content {
  355. display: flex;
  356. margin-top: 30px;
  357. .tabs2 {
  358. height: 560px;
  359. overflow-y: auto;
  360. .tab {
  361. /*width: 399px;*/
  362. width: 600px;
  363. height: 70px;
  364. background: url('@/assets/images/plan/tab2.png') no-repeat;
  365. display: flex;
  366. align-items: center;
  367. padding-left: 76px;
  368. color: #9badc4;
  369. font-size: 36px;
  370. font-weight: bold;
  371. margin-top: 60px;
  372. position: relative;
  373. cursor: pointer;
  374. .text {
  375. white-space:nowrap;
  376. }
  377. &::before {
  378. content: '';
  379. width: 2px;
  380. height: 68px;
  381. background: #2b88bd;
  382. position: absolute;
  383. top: -63px;
  384. left: 42px;
  385. }
  386. &:first-child {
  387. margin-top: 0;
  388. &::before {
  389. display: none;
  390. }
  391. }
  392. &:hover {
  393. /*width: 439px;*/
  394. width: 600px;
  395. background: url('@/assets/images/plan/tab2Active.png') no-repeat;
  396. .text {
  397. /* 设置字体透明 */
  398. color: transparent;
  399. /* 设置线性渐变,从红色渐变到蓝色 */
  400. background-image: linear-gradient(to bottom, #fff 30%, #57c3fc 50%, #3aa1ea 100%);
  401. /* 使用 -webkit-background-clip 属性将背景剪裁至文本形状 */
  402. -webkit-background-clip: text;
  403. /* 非Webkit内核浏览器需要使用标准前缀 */
  404. background-clip: text;
  405. /* 把当前元素设置为行内块,以便能够应用背景 */
  406. display: inline-block;
  407. }
  408. }
  409. }
  410. .tab-active2 {
  411. /*width: 439px;*/
  412. width: 600px;
  413. background: url('@/assets/images/plan/tab2Active.png') no-repeat;
  414. .text {
  415. /* 设置字体透明 */
  416. color: transparent;
  417. /* 设置线性渐变,从红色渐变到蓝色 */
  418. background-image: linear-gradient(to bottom, #fff 40%, #5cc4fa 50%, #40a2e7 100%);
  419. /* 使用 -webkit-background-clip 属性将背景剪裁至文本形状 */
  420. -webkit-background-clip: text;
  421. /* 非Webkit内核浏览器需要使用标准前缀 */
  422. background-clip: text;
  423. /* 把当前元素设置为行内块,以便能够应用背景 */
  424. display: inline-block;
  425. }
  426. }
  427. }
  428. .tab-content2 {
  429. padding-left: 20px;
  430. height: 560px;
  431. flex: 1;
  432. overflow-y: auto;
  433. }
  434. }
  435. </style>