From 34a007951daf79f8d549ceb811d7fa9ed3fab6fd Mon Sep 17 00:00:00 2001 From: ali <ali9696@163.com> Date: 星期一, 20 一月 2025 11:14:05 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/develop1.0' into develop_alioo --- zhitan-system/src/main/java/com/zhitan/knowledgeBase/domain/vo/KnowledgeBasePageVO.java | 5 zhitan-vue/src/components/FileUpload/index.vue | 1 zhitan-vue/src/views/login.vue | 1 zhitan-system/src/main/java/com/zhitan/knowledgeBase/service/impl/KnowledgeBaseServiceImpl.java | 22 +- zhitan-vue/src/api/policy/knowledgeBase.js | 48 ++++++ zhitan-vue/src/views/policy/knowledgebase/components/EditModal.vue | 104 +++++++++++++ zhitan-vue/src/views/policy/knowledgebase/knowledgeBase.vue | 130 ++++++++++++++++ zhitan-admin/src/main/java/com/zhitan/web/controller/auxiliaryinput/ProductOutputController.java | 60 ++---- zhitan-admin/src/main/java/com/zhitan/web/controller/homepage/HomePageController.java | 45 ++--- zhitan-admin/src/main/java/com/zhitan/web/controller/alarm/AlarmAnalyisisController.java | 2 zhitan-system/src/main/java/com/zhitan/knowledgeBase/domain/vo/KnowledgeBaseDetailVO.java | 3 11 files changed, 342 insertions(+), 79 deletions(-) diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/alarm/AlarmAnalyisisController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/alarm/AlarmAnalyisisController.java index bcc801c..8766e28 100644 --- a/zhitan-admin/src/main/java/com/zhitan/web/controller/alarm/AlarmAnalyisisController.java +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/alarm/AlarmAnalyisisController.java @@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RestController; /** - * description todu +geng * description 鎶ヨ鍒嗘瀽鐩稿叧鍔熻兘 * * @author hmj * @date 2024-10-26 17:31 diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/auxiliaryinput/ProductOutputController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/auxiliaryinput/ProductOutputController.java index c3abae5..2b253e2 100644 --- a/zhitan-admin/src/main/java/com/zhitan/web/controller/auxiliaryinput/ProductOutputController.java +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/auxiliaryinput/ProductOutputController.java @@ -34,10 +34,9 @@ */ @PreAuthorize("@ss.hasPermi('system:prodoutput:list')") @GetMapping("/productoutput/list") - public TableDataInfo list(ProductOutput productOutput, @RequestParam Long pageNum, @RequestParam Long pageSize) - { + public TableDataInfo list(ProductOutput productOutput, @RequestParam Long pageNum, @RequestParam Long pageSize) { productOutput.setDataType("1"); - Page<ProductOutput> list = auxiliaryInputService.selectProductOutputPage(productOutput,pageNum,pageSize); + Page<ProductOutput> list = auxiliaryInputService.selectProductOutputPage(productOutput, pageNum, pageSize); return getDataTable(list); } @@ -47,8 +46,7 @@ @PreAuthorize("@ss.hasPermi('system:prodoutput:export')") @Log(title = "浜у搧浜ч噺褰曞叆", businessType = BusinessType.EXPORT) @PostMapping("/productoutput/export") - public void export(HttpServletResponse response, ProductOutput productOutput) - { + public void export(HttpServletResponse response, ProductOutput productOutput) { productOutput.setDataType("1"); List<ProductOutput> list = auxiliaryInputService.selectProductOutputList(productOutput); ExcelUtil<ProductOutput> util = new ExcelUtil<ProductOutput>(ProductOutput.class); @@ -60,8 +58,7 @@ */ @PreAuthorize("@ss.hasPermi('system:prodoutput:query')") @GetMapping(value = "/productoutput/{productOutputId}") - public AjaxResult getInfo(@PathVariable("productOutputId") String productOutputId) - { + public AjaxResult getInfo(@PathVariable("productOutputId") String productOutputId) { return success(auxiliaryInputService.selectProductOutputById(productOutputId)); } @@ -71,8 +68,7 @@ @PreAuthorize("@ss.hasPermi('system:prodoutput:add')") @Log(title = "浜у搧浜ч噺褰曞叆", businessType = BusinessType.INSERT) @PostMapping(value = "/productoutput") - public AjaxResult add(@RequestBody ProductOutput productOutput) - { + public AjaxResult add(@RequestBody ProductOutput productOutput) { productOutput.setProductOutputId(UUID.randomUUID().toString()); productOutput.setDataType("1"); return toAjax(auxiliaryInputService.insertProductOutput(productOutput)); @@ -84,8 +80,7 @@ @PreAuthorize("@ss.hasPermi('system:prodoutput:edit')") @Log(title = "浜у搧浜ч噺褰曞叆", businessType = BusinessType.UPDATE) @PutMapping(value = "/productoutput") - public AjaxResult edit(@RequestBody ProductOutput productOutput) - { + public AjaxResult edit(@RequestBody ProductOutput productOutput) { return toAjax(auxiliaryInputService.updateProductOutput(productOutput)); } @@ -95,8 +90,7 @@ @PreAuthorize("@ss.hasPermi('system:prodoutput:remove')") @Log(title = "浜у搧浜ч噺褰曞叆", businessType = BusinessType.DELETE) @DeleteMapping("/productoutput/{ids}") - public AjaxResult remove(@PathVariable String[] ids) - { + public AjaxResult remove(@PathVariable String[] ids) { return toAjax(auxiliaryInputService.deleteProductOutputByIds(ids)); } @@ -106,10 +100,9 @@ */ @PreAuthorize("@ss.hasPermi('system:meter:list')") @GetMapping("/meter/list") - public TableDataInfo meterList(ProductOutput productOutput, @RequestParam Long pageNum, @RequestParam Long pageSize) - { + public TableDataInfo meterList(ProductOutput productOutput, @RequestParam Long pageNum, @RequestParam Long pageSize) { productOutput.setDataType("2"); - Page<ProductOutput> list = auxiliaryInputService.selectProductOutputPage(productOutput,pageNum,pageSize); + Page<ProductOutput> list = auxiliaryInputService.selectProductOutputPage(productOutput, pageNum, pageSize); return getDataTable(list); } @@ -119,8 +112,7 @@ @PreAuthorize("@ss.hasPermi('system:meter:export')") @Log(title = "鑳芥簮浠〃褰曞叆", businessType = BusinessType.EXPORT) @PostMapping("/meter/export") - public void meterExport(HttpServletResponse response, ProductOutput productOutput) - { + public void meterExport(HttpServletResponse response, ProductOutput productOutput) { productOutput.setDataType("2"); List<ProductOutput> list = auxiliaryInputService.selectProductOutputList(productOutput); ExcelUtil<ProductOutput> util = new ExcelUtil<ProductOutput>(ProductOutput.class); @@ -132,8 +124,7 @@ */ @PreAuthorize("@ss.hasPermi('system:meter:query')") @GetMapping(value = "/meter/{productOutputId}") - public AjaxResult meterGetInfo(@PathVariable("productOutputId") String productOutputId) - { + public AjaxResult meterGetInfo(@PathVariable("productOutputId") String productOutputId) { return success(auxiliaryInputService.selectProductOutputById(productOutputId)); } @@ -143,8 +134,7 @@ @PreAuthorize("@ss.hasPermi('system:meter:add')") @Log(title = "鑳芥簮浠〃褰曞叆", businessType = BusinessType.INSERT) @PostMapping(value = "/meter") - public AjaxResult meterAdd(@RequestBody ProductOutput productOutput) - { + public AjaxResult meterAdd(@RequestBody ProductOutput productOutput) { productOutput.setProductOutputId(UUID.randomUUID().toString()); productOutput.setDataType("2"); return toAjax(auxiliaryInputService.insertProductOutput(productOutput)); @@ -156,8 +146,7 @@ @PreAuthorize("@ss.hasPermi('system:meter:edit')") @Log(title = "鑳芥簮浠〃褰曞叆", businessType = BusinessType.UPDATE) @PutMapping(value = "/meter") - public AjaxResult meterEdit(@RequestBody ProductOutput productOutput) - { + public AjaxResult meterEdit(@RequestBody ProductOutput productOutput) { return toAjax(auxiliaryInputService.updateProductOutput(productOutput)); } @@ -167,8 +156,7 @@ @PreAuthorize("@ss.hasPermi('system:meter:remove')") @Log(title = "鑳芥簮浠〃褰曞叆", businessType = BusinessType.DELETE) @DeleteMapping("/meter/{ids}") - public AjaxResult meterRemove(@PathVariable String[] ids) - { + public AjaxResult meterRemove(@PathVariable String[] ids) { return toAjax(auxiliaryInputService.deleteProductOutputByIds(ids)); } @@ -177,10 +165,9 @@ */ @PreAuthorize("@ss.hasPermi('system:energyindex:list')") @GetMapping("/energyindex/list") - public TableDataInfo energyIndexList(ProductOutput productOutput, @RequestParam Long pageNum, @RequestParam Long pageSize) - { + public TableDataInfo energyIndexList(ProductOutput productOutput, @RequestParam Long pageNum, @RequestParam Long pageSize) { productOutput.setDataType("3"); - Page<ProductOutput> list = auxiliaryInputService.selectProductOutputPage(productOutput,pageNum,pageSize); + Page<ProductOutput> list = auxiliaryInputService.selectProductOutputPage(productOutput, pageNum, pageSize); return getDataTable(list); } @@ -190,8 +177,7 @@ @PreAuthorize("@ss.hasPermi('system:energyindex:export')") @Log(title = "鑳芥簮鎸囨爣褰曞叆", businessType = BusinessType.EXPORT) @PostMapping("/energyindex/export") - public void energyIndexExport(HttpServletResponse response, ProductOutput productOutput) - { + public void energyIndexExport(HttpServletResponse response, ProductOutput productOutput) { productOutput.setDataType("3"); List<ProductOutput> list = auxiliaryInputService.selectProductOutputList(productOutput); ExcelUtil<ProductOutput> util = new ExcelUtil<ProductOutput>(ProductOutput.class); @@ -203,8 +189,7 @@ */ @PreAuthorize("@ss.hasPermi('system:energyindex:query')") @GetMapping(value = "/energyindex/{productOutputId}") - public AjaxResult energyIndexGetInfo(@PathVariable("productOutputId") String productOutputId) - { + public AjaxResult energyIndexGetInfo(@PathVariable("productOutputId") String productOutputId) { return success(auxiliaryInputService.selectProductOutputById(productOutputId)); } @@ -214,8 +199,7 @@ @PreAuthorize("@ss.hasPermi('system:energyindex:add')") @Log(title = "鑳芥簮鎸囨爣褰曞叆", businessType = BusinessType.INSERT) @PostMapping(value = "/energyindex") - public AjaxResult energyIndexAdd(@RequestBody ProductOutput productOutput) - { + public AjaxResult energyIndexAdd(@RequestBody ProductOutput productOutput) { productOutput.setProductOutputId(UUID.randomUUID().toString()); productOutput.setDataType("3"); return toAjax(auxiliaryInputService.insertProductOutput(productOutput)); @@ -227,8 +211,7 @@ @PreAuthorize("@ss.hasPermi('system:energyindex:edit')") @Log(title = "鑳芥簮鎸囨爣褰曞叆", businessType = BusinessType.UPDATE) @PutMapping(value = "/energyindex") - public AjaxResult energyIndexEdit(@RequestBody ProductOutput productOutput) - { + public AjaxResult energyIndexEdit(@RequestBody ProductOutput productOutput) { return toAjax(auxiliaryInputService.updateProductOutput(productOutput)); } @@ -238,8 +221,7 @@ @PreAuthorize("@ss.hasPermi('system:energyindex:remove')") @Log(title = "鑳芥簮鎸囨爣褰曞叆", businessType = BusinessType.DELETE) @DeleteMapping("/energyindex/{ids}") - public AjaxResult energyIndexRemove(@PathVariable String[] ids) - { + public AjaxResult energyIndexRemove(@PathVariable String[] ids) { return toAjax(auxiliaryInputService.deleteProductOutputByIds(ids)); } diff --git a/zhitan-admin/src/main/java/com/zhitan/web/controller/homepage/HomePageController.java b/zhitan-admin/src/main/java/com/zhitan/web/controller/homepage/HomePageController.java index 00cff85..d101c3e 100644 --- a/zhitan-admin/src/main/java/com/zhitan/web/controller/homepage/HomePageController.java +++ b/zhitan-admin/src/main/java/com/zhitan/web/controller/homepage/HomePageController.java @@ -25,30 +25,24 @@ @Autowired public IHomePageService homepageService; - /** - * @description: 鍏ㄥ巶鑳借�楃粺璁� - * @param timeType - * @return - * @author: hmj - * @date: 2024/10/8 13:41 - */ - @GetMapping("/energyConsumptionSummation") - public AjaxResult energyConsumptionSummation(String timeType) { - try { -// String modelcode = "Composite_Indicators"; - String modelcode = "COMPREHENSIVE_CODE"; - return AjaxResult.success(homepageService.energyConsumptionSummation(timeType,modelcode)); - } catch (Exception ex) { - logger.error("鑾峰彇鍑洪敊锛�", ex); - return AjaxResult.error("鑾峰彇鍑洪敊!"); - } - } + + /** + * @description: 鍏ㄥ巶鑳借�楃粺璁� + */ + @GetMapping("/energyConsumptionSummation") + public AjaxResult energyConsumptionSummation(String timeType) { + try { + String modelcode = "COMPREHENSIVE_CODE"; + return AjaxResult.success(homepageService.energyConsumptionSummation(timeType, modelcode)); + } catch (Exception ex) { + logger.error("鑾峰彇鍑洪敊锛�", ex); + return AjaxResult.error("鑾峰彇鍑洪敊!"); + } + } /** * @description: 鑳借�楄秼鍔� - * @param timeType - * @return * @author: hmj * @date: 2024/10/8 13:41 */ @@ -56,7 +50,7 @@ public AjaxResult energyConsumptionTrend(String timeType) { try { String modelcode = "COMPREHENSIVE_CODE"; - HomeEnergyConsumptionTrendVO vo = homepageService.energyConsumptionTrend(timeType,modelcode); + HomeEnergyConsumptionTrendVO vo = homepageService.energyConsumptionTrend(timeType, modelcode); return AjaxResult.success(vo); } catch (Exception ex) { @@ -67,8 +61,6 @@ /** * @description: 绉戝鑳借�楁帓鍚� - * @param timeType - * @return * @author: hmj * @date: 2024/10/8 13:41 */ @@ -76,7 +68,7 @@ public AjaxResult energyConsumptionRanking(String timeType) { try { String modelcode = "COMPREHENSIVE_CODE"; - List<RankingEnergyData> consumptionAnalysisVO = homepageService.energyConsumptionRanking(modelcode,timeType); + List<RankingEnergyData> consumptionAnalysisVO = homepageService.energyConsumptionRanking(modelcode, timeType); return AjaxResult.success(consumptionAnalysisVO); } catch (Exception ex) { logger.error("鑾峰彇鍑洪敊锛�", ex); @@ -86,17 +78,14 @@ /** * @description: 宄板钩璋峰崰姣� - * @param timeType - * @return * @author: hmj * @date: 2024/10/8 13:41 */ @GetMapping("/peakValley") public AjaxResult peakValley(String timeType) { try { -// String modelcode = "Composite_Indicators"; String modelcode = "COMPREHENSIVE_CODE"; - List<HomePeakValleyVO> vo = homepageService.peakValley(timeType,modelcode); + List<HomePeakValleyVO> vo = homepageService.peakValley(timeType, modelcode); return AjaxResult.success(vo); } catch (Exception ex) { logger.error("鑾峰彇鍑洪敊锛�", ex); diff --git a/zhitan-system/src/main/java/com/zhitan/knowledgeBase/domain/vo/KnowledgeBaseDetailVO.java b/zhitan-system/src/main/java/com/zhitan/knowledgeBase/domain/vo/KnowledgeBaseDetailVO.java index 099829e..9796ccb 100644 --- a/zhitan-system/src/main/java/com/zhitan/knowledgeBase/domain/vo/KnowledgeBaseDetailVO.java +++ b/zhitan-system/src/main/java/com/zhitan/knowledgeBase/domain/vo/KnowledgeBaseDetailVO.java @@ -1,5 +1,7 @@ package com.zhitan.knowledgeBase.domain.vo; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -17,6 +19,7 @@ * id */ @ApiModelProperty(value = "id") + @JsonSerialize(using = ToStringSerializer.class) private Long id; /** * 鏍囬 diff --git a/zhitan-system/src/main/java/com/zhitan/knowledgeBase/domain/vo/KnowledgeBasePageVO.java b/zhitan-system/src/main/java/com/zhitan/knowledgeBase/domain/vo/KnowledgeBasePageVO.java index 22b923d..0ef28d5 100644 --- a/zhitan-system/src/main/java/com/zhitan/knowledgeBase/domain/vo/KnowledgeBasePageVO.java +++ b/zhitan-system/src/main/java/com/zhitan/knowledgeBase/domain/vo/KnowledgeBasePageVO.java @@ -1,5 +1,8 @@ package com.zhitan.knowledgeBase.domain.vo; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import lombok.Data; /** @@ -11,6 +14,7 @@ /** * id */ + @JsonSerialize(using = ToStringSerializer.class) private Long id; /** * 鏍囬 @@ -31,5 +35,6 @@ /** * 鍒涘缓鏃堕棿 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private String createTime; } diff --git a/zhitan-system/src/main/java/com/zhitan/knowledgeBase/service/impl/KnowledgeBaseServiceImpl.java b/zhitan-system/src/main/java/com/zhitan/knowledgeBase/service/impl/KnowledgeBaseServiceImpl.java index 44f17b7..390231d 100644 --- a/zhitan-system/src/main/java/com/zhitan/knowledgeBase/service/impl/KnowledgeBaseServiceImpl.java +++ b/zhitan-system/src/main/java/com/zhitan/knowledgeBase/service/impl/KnowledgeBaseServiceImpl.java @@ -48,12 +48,14 @@ // 鍒嗛〉鏌ヨ Page<KnowledgeBase> knowledgeBasePage = baseMapper.selectPage(new Page<>(pageDTO.getPageNum(), pageDTO.getPageSize()), Wrappers.<KnowledgeBase>lambdaQuery() + .select(KnowledgeBase::getId, KnowledgeBase::getTitle, KnowledgeBase::getType, + KnowledgeBase::getContent, KnowledgeBase::getCreateTime) .like(ObjectUtils.isNotEmpty(pageDTO.getTitle()), KnowledgeBase::getTitle, pageDTO.getTitle()) .eq(ObjectUtils.isNotEmpty(pageDTO.getType()), KnowledgeBase::getType, pageDTO.getType()) .eq(KnowledgeBase::getDelFlag, false).orderByDesc(KnowledgeBase::getCreateTime)); List<KnowledgeBase> records = knowledgeBasePage.getRecords(); - if (records.isEmpty()){ + if (records.isEmpty()) { return voPage; } // 鏁版嵁杞崲 @@ -75,12 +77,12 @@ // 鏌ヨ鏁版嵁 KnowledgeBase knowledgeBase = baseMapper.selectById(id); - if (knowledgeBase != null){ + if (knowledgeBase != null) { // 鏁版嵁杞崲 BeanUtil.copyProperties(knowledgeBase, vo); vo.setUrl(fileMapper.selectList(Wrappers.<KnowledgeBaseFile>lambdaQuery() - .select(KnowledgeBaseFile::getUrl) - .eq(KnowledgeBaseFile::getKnowledgeBaseId, id)) + .select(KnowledgeBaseFile::getUrl) + .eq(KnowledgeBaseFile::getKnowledgeBaseId, id)) .stream().map(KnowledgeBaseFile::getUrl).collect(Collectors.toList())); } return vo; @@ -97,8 +99,8 @@ baseMapper.insert(knowledgeBase); // 鎻掑叆鏂囦欢 - if (ObjectUtils.isNotEmpty(addDTO.getUrl())){ - addDTO.getUrl().forEach(url->{ + if (ObjectUtils.isNotEmpty(addDTO.getUrl())) { + addDTO.getUrl().forEach(url -> { KnowledgeBaseFile file = new KnowledgeBaseFile(); file.setKnowledgeBaseId(knowledgeBase.getId()); file.setUrl(url); @@ -114,7 +116,7 @@ public void edit(KnowledgeBaseEditDTO editDTO) { // 鏌ヨ鏁版嵁 KnowledgeBase knowledgeBase = baseMapper.selectById(editDTO.getId()); - if (ObjectUtils.isEmpty(knowledgeBase)){ + if (ObjectUtils.isEmpty(knowledgeBase)) { throw new ServiceException(MessageConstant.KNOWLEDGE_BASE_NOT_EXIST); } // 鏇存柊鏁版嵁 @@ -126,8 +128,8 @@ .eq(KnowledgeBaseFile::getKnowledgeBaseId, knowledgeBase.getId())); // 鎻掑叆鏂囦欢 - if (ObjectUtils.isNotEmpty(editDTO.getUrl())){ - editDTO.getUrl().forEach(url->{ + if (ObjectUtils.isNotEmpty(editDTO.getUrl())) { + editDTO.getUrl().forEach(url -> { KnowledgeBaseFile file = new KnowledgeBaseFile(); file.setKnowledgeBaseId(knowledgeBase.getId()); file.setUrl(url); @@ -143,7 +145,7 @@ public void delete(Long id) { // 鏌ヨ鏁版嵁 KnowledgeBase knowledgeBase = baseMapper.selectById(id); - if (ObjectUtils.isEmpty(knowledgeBase)){ + if (ObjectUtils.isEmpty(knowledgeBase)) { throw new ServiceException(MessageConstant.KNOWLEDGE_BASE_NOT_EXIST); } // 鍒犻櫎鏁版嵁 diff --git a/zhitan-vue/src/api/policy/knowledgeBase.js b/zhitan-vue/src/api/policy/knowledgeBase.js new file mode 100644 index 0000000..573e1ad --- /dev/null +++ b/zhitan-vue/src/api/policy/knowledgeBase.js @@ -0,0 +1,48 @@ +import request from '@/utils/request' + + + + +// 鑾峰彇鍒楄〃 +export function knowledgeBaseList(params) { + return request({ + url: '/knowledgeBase/page', + method: 'get', + params + }) +} + +// 鏂板 +export function knowledgeBaseAdd(data) { + return request({ + url: '/knowledgeBase/add', + method: 'post', + data + }) +} + +// 鏌ヨ鎯� +export function knowledgeBaseInfo(params) { + return request({ + url: `/knowledgeBase/detail/${params.id}`, + method: 'get', + params + }) +} + +// 缂栬緫 +export function knowledgeBaseEdit(data) { + return request({ + url: '/knowledgeBase/edit', + method: 'post', + data + }) +} + +//鍒犻櫎 +export function knowledgeBaseDel(id) { + return request({ + url: '/knowledgeBase/delete/' + id, + method: 'delete', + }) +} \ No newline at end of file diff --git a/zhitan-vue/src/components/FileUpload/index.vue b/zhitan-vue/src/components/FileUpload/index.vue index 2af9672..4b76324 100644 --- a/zhitan-vue/src/components/FileUpload/index.vue +++ b/zhitan-vue/src/components/FileUpload/index.vue @@ -40,7 +40,6 @@ <script setup> import { getToken } from "@/utils/auth"; - const props = defineProps({ modelValue: [String, Object, Array], // 鏁伴噺闄愬埗 diff --git a/zhitan-vue/src/views/login.vue b/zhitan-vue/src/views/login.vue index b58823d..86d243f 100644 --- a/zhitan-vue/src/views/login.vue +++ b/zhitan-vue/src/views/login.vue @@ -21,6 +21,7 @@ size="large" auto-complete="off" placeholder="瀵嗙爜" + show-password @keyup.enter="handleLogin" > <template #prefix><svg-icon icon-class="password" class="el-input__icon input-icon" /></template> diff --git a/zhitan-vue/src/views/policy/knowledgebase/components/EditModal.vue b/zhitan-vue/src/views/policy/knowledgebase/components/EditModal.vue new file mode 100644 index 0000000..9aaf0d0 --- /dev/null +++ b/zhitan-vue/src/views/policy/knowledgebase/components/EditModal.vue @@ -0,0 +1,104 @@ +<template> + <el-dialog v-model="visible" :title="title" width="600" @close="handleClose"> + <el-form :model="form" ref="queryRef" :rules="formRules" label-width="100px" v-loading="loading"> + <el-form-item label="鏍囬" prop="title"> + <el-input v-model="form.title" placeholder="璇疯緭鍏ユ爣棰�" /> + </el-form-item> + <el-form-item label="鑳芥簮绫诲瀷" prop="type"> + <el-select v-model="form.type" placeholder="璇烽�夋嫨" style="width: 100%;"> + <el-option v-for="(item, index) in props.types" :key="index" :label="item.label" + :value="item.value"> + </el-option> + </el-select> + </el-form-item> + <el-form-item label="鍐呭" prop="content"> + <el-input v-model="form.content" placeholder="璇疯緭鍏ュ唴瀹�" /> + </el-form-item> + <!-- <el-form-item label="闄勪欢" prop="url"> + <FileUpload></FileUpload> + </el-form-item> --> + </el-form> + <div slot="footer" class="text-right"> + <el-button type="primary" @click="submitForm" :loading="loading">纭� 瀹�</el-button> + <el-button @click="handleClose">鍙� 娑�</el-button> + </div> + </el-dialog> +</template> + +<script setup> +import { knowledgeBaseAdd, knowledgeBaseEdit } from '@/api/policy/knowledgeBase' +const { proxy } = getCurrentInstance(); +let props = defineProps(['types']) + + +let visible = ref(false) +let title = ref('') +let loading = ref(false) +let form = ref({ + title: '', + content: '', + type: null, + url:[] +}) +let emit = defineEmits(['getList']) +const formRules = { + title: [{ required: true, trigger: "blur", message: "璇疯緭鍏ユ爣棰�" }], + type: [{ required: true, trigger: "change", message: "璇烽�夋嫨鑳芥簮绫诲瀷" }], + content: [{ required: true, trigger: "blur", message: "璇疯緭鍏ュ唴瀹�" }], +} + +function submitForm() { + proxy.$refs.queryRef.validate(valid => { + if (valid) { + loading.value = true; + let obj = form.value.id ? knowledgeBaseEdit(form.value) : knowledgeBaseAdd(form.value) + obj.then((res) => { + if (res.code == 200) { + proxy.$modal.msgSuccess(res.msg); + emit('getList') + } else { + proxy.$modal.msgError(res.msg); + } + + }).catch((err) => { + + }).finally(() => { + handleClose() + }); + } + }) +} + + + + + +function handleOpen(row) { + if (row && row.id) { + title.value = "缂栬緫鐭ヨ瘑搴�" + form.value = JSON.parse(JSON.stringify(row)) + } else { + title.value = "娣诲姞鐭ヨ瘑搴�" + } + visible.value = true +} + +function handleClose(value) { + visible.value = false + loading.value = false + proxy.$refs.queryRef.resetFields() + form.value = { + title: '', + content: '', + type: null, + url:[] + } +} + +defineExpose({ handleOpen }) + +</script> + + + +<style lang="scss" scoped></style> diff --git a/zhitan-vue/src/views/policy/knowledgebase/knowledgeBase.vue b/zhitan-vue/src/views/policy/knowledgebase/knowledgeBase.vue new file mode 100644 index 0000000..e8f32a2 --- /dev/null +++ b/zhitan-vue/src/views/policy/knowledgebase/knowledgeBase.vue @@ -0,0 +1,130 @@ +<template> + <div class="page"> + <div class="form-card"> + <el-form :model="queryParams" ref="queryRef" :inline="true" label-width="120px"> + <el-form-item label="鏍囬"> + <el-input v-model="queryParams.title" placeholder="璇疯緭鍏ユ爣棰�" clearable/> + </el-form-item> + <el-form-item label="鑳芥簮绫诲瀷"> + <el-select v-model="queryParams.type" placeholder="璇烽�夋嫨鑳芥簮绫诲瀷" style="width: 100%" clearable> + <el-option v-for="dict in types" :key="dict.value" + :label="dict.label" :value="dict.value" /> + </el-select> + </el-form-item> + <el-form-item> + <el-button type="primary" icon="Search" @click="handleQuery">鎼滅储</el-button> + <el-button icon="Refresh" @click="resetQuery">閲嶇疆</el-button> + </el-form-item> + </el-form> + </div> + + <div class="table-bg-style"> + <div class="theme-dark-mt20 mb20 ml20"> + <el-button type="primary" icon="plus" @click="handleAdd">鏂板</el-button> + <!-- <el-button type="primary" icon="Delete">鍒犻櫎</el-button> --> + </div> + <div class="table-box"> + <el-table :data="tableData" v-loading="loading"> + <el-table-column prop="title" label="鏍囬" show-overflow-tooltip align="center" /> + <el-table-column prop="typeDesc" label="鑳芥簮绫诲瀷" show-overflow-tooltip align="center" /> + <el-table-column prop="content" label="鍐呭" show-overflow-tooltip align="center" /> + <el-table-column prop="createTime" label="鍒涘缓鏃堕棿" show-overflow-tooltip align="center" /> + <el-table-column label="鎿嶄綔" width="300" align="center"> + <template #default="scope"> + <el-button link type="primary" icon="Edit" @click="handleAdd(scope.row)"> 淇敼 </el-button> + <el-button link type="primary" icon="Delete" @click="handleDel(scope.row)"> 鍒犻櫎 </el-button> + </template> + </el-table-column> + </el-table> + + <pagination + v-show="total > 0" + :total="total" + v-model:page="queryParams.pageNum" + v-model:limit="queryParams.pageSize" + @pagination="getList" + /> + </div> + </div> + <edit-modal ref="EditModalRef" @getList="getList" :types="types" /> + </div> +</template> + +<script setup> + import EditModal from "./components/EditModal.vue" +import { knowledgeBaseList, knowledgeBaseDel } from "@/api/policy/knowledgeBase" +let { proxy } = getCurrentInstance() +const types = ref([ + { label: "鐢�", value: 0 }, + { label: "姘�", value: 1 }, + { label: "澶╃劧姘�", value: 2 }, + { label: "钂告苯", value: 3 }, +]); +let loading = ref(false) +let total = ref(0) +let tableData = ref([]) +let queryParams = ref({ + title: "", + type:null, + pageNum: 1, + pageSize: 10, +}) + +function getList() { + loading.value = true + knowledgeBaseList(queryParams.value).then((res) => { + console.log(res.rows) + tableData.value = res.rows + total.value = res.total + loading.value = false + }) +} + +getList() + +let EditModalRef = ref("") +function handleAdd(row) { + if (EditModalRef.value) { + EditModalRef.value.handleOpen(row) + } +} + +function handleDel(row) { + proxy.$modal + .confirm("鏄惁纭鍒犻櫎鏁版嵁椤�?") + .then(function () { + return knowledgeBaseDel(row.id) + }) + .then(() => { + getList() + proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛") + }) + .catch(() => {}) +} + +function handleQuery() { + queryParams.value.pageNum = 1 + getList() +} + +function resetQuery() { + queryParams.value = { + title: "", + type:null, + pageNum: 1, + pageSize: 10, + } + getList() +} +</script> + +<style lang="scss" scoped> +@import "@/assets/styles/page.scss"; + +.header-box { + :deep .el-form-item__content { + color: #fff; + font-size: 16px; + } +} +</style> -- Gitblit v1.9.3