This commit is contained in:
2025-04-02 19:16:28 +08:00
parent 9d3945413a
commit e43f9230eb
31 changed files with 513 additions and 188 deletions

View File

@@ -68,7 +68,7 @@ export default {
})
},
/**
* 添加字典Item数据
* 添加dictItem数据
* @returns
*/
saveDictItem(data = {}) {
@@ -99,5 +99,27 @@ export default {
method: "delete",
data
})
},
/**
* 快速新增字典项(非字典)
* @returns 成功或失败
*/
createDictItemFast(data = {}) {
return request({
url: "system/dataDict/fastSave",
method: "post",
data
})
},
/**
* 快速新增依据标准字典项(非字典)
* @returns 成功或失败
*/
createDictItemStdFast(data = {}) {
return request({
url: "system/dataDict/saveStdItem",
method: "post",
data
})
}
}

View File

@@ -1,7 +1,3 @@
<!--
- @Author XXX
- @Link XXX
-->
<template>
<a-spin :loading="searchLoading" :tip="options.searchLoadingText" v-if="showSearch">
<a-form
@@ -28,7 +24,7 @@
</a-form-item>
</template>
</div>
<div class="text-center mt-5 w-full" v-if="searchColumns.length > 0">
<div class="text-center mt-2 w-full" v-if="searchColumns.length > 0">
<a-space size="medium">
<slot name="searchBeforeButtons" />
<slot name="searchButtons">

View File

@@ -25,9 +25,9 @@
</a-space>
<a-alert type="warning" class="mt-2"
>排序本页是指当前页排序服务器是指后台排序若自定义服务器排序可用
<a-tag>@sorterChange</a-tag> 事件来实现</a-alert
>
>排序本页是指当前页排序服务器是指后台排序后台排序暂无
<!-- <a-tag>@sorterChange</a-tag> 事件来实现 -->
</a-alert>
<a-table
:data="allowShowColumns"
:pagination="false"

View File

@@ -1,6 +1,6 @@
<template>
<a-layout-content class="flex flex-col lg:h-full relative w-full">
<div class="_crud-header flex flex-col mb-2" ref="crudHeaderRef">
<div class="_crud-header flex flex-col mb-1" ref="crudHeaderRef">
<a-tabs
v-if="isArray(options.tabs.data) && options.tabs.data.length > 0"
v-model:active-key="options.tabs.defaultKey"

View File

@@ -1,7 +1,3 @@
<!--
- @Author XXX
- @Link XXX
-->
<template>
<ma-form-item
v-if="typeof props.component.display == 'undefined' || props.component.display === true"
@@ -130,6 +126,87 @@
</a-pagination>
</div>
</template>
<!-- 改动1、2、3下面template都是改动内容 -->
<template #footer v-else-if="component.allowCreate">
<div style="padding: 6px 0; text-align: center">
<!-- 新增columns属性onCreate -->
<a-popover
:title="component.createInfo ? component.createInfo.title : '无标题'"
trigger="click"
>
<a-button size="small" type="primary">点击新增</a-button>
<template #content>
<a-row :wrap="false">
<a-input
:style="{ width: '320px' }"
:placeholder="`请输入新增的${component.createInfo.title}`"
allow-clear
v-model="createItem"
/>
<a-button
type="primary"
@click="handleCreteSubmit(component.onCreate)"
:loading="createLoading"
>提交</a-button
>
</a-row>
</template>
</a-popover>
</div>
</template>
<template #footer v-else-if="component.allowNew && !component.allowCreate">
<div style="padding: 6px 0; text-align: center">
<a-popover :title="component.newInfo ? component.newInfo.title : '无标题'" trigger="click">
<a-button size="small" type="primary">快速新增</a-button>
<template #content>
<ma-form
@submit="handleContactFormSubmit"
v-model="contactFormData"
:columns="contactFormOptions"
ref="contactForm"
></ma-form>
</template>
</a-popover>
</div>
</template>
<template #footer v-else-if="component.allowAbbrNew && !component.allowCreate && !component.allowNew">
<div style="padding: 6px 0; text-align: center">
<a-popover
:title="component.abbrNewInfo ? component.abbrNewInfo.title : '无标题'"
trigger="click"
>
<a-button size="small" type="primary">快速新增缩略语</a-button>
<template #content>
<ma-form
@submit="handleAbbrFormSubmit"
v-model="abbrFormData"
:columns="abbrFormOptions"
ref="abbrForm"
></ma-form>
</template>
</a-popover>
</div>
</template>
<template
#footer
v-else-if="
component.allowStd && !component.allowAbbrNew && !component.allowCreate && !component.allowNew
"
>
<div style="padding: 6px 0; text-align: center">
<a-popover :title="component.stdInfo ? component.stdInfo.title : '无标题'" trigger="click">
<a-button size="small" type="primary">快速新增依据标准</a-button>
<template #content>
<ma-form
@submit="handleStdFormSubmit"
v-model="stdFormData"
:columns="stdFormOptions"
ref="stdForm"
></ma-form>
</template>
</a-popover>
</div>
</template>
</a-select>
</slot>
</ma-form-item>
@@ -141,6 +218,138 @@ import MaFormItem from "./form-item.vue"
import { get, isUndefined, set, xor, isObject, isBoolean } from "lodash-es"
import { runEvent } from "../js/event.js"
import { handlerCascader, loadDict } from "../js/networkRequest.js"
import { Message, Notification } from "@arco-design/web-vue"
// 改动2快速新增联系单位信息[耦合内容] - start
import { columnsOptions as contactColumnOption } from "@/views/datamanage/projContact/crudColumns"
import { columnsOptions as abbrColumnOption } from "@/views/datamanage/abbreviation/columnsOptions"
import useDictItemCrud from "@/views/datamanage/dictmanage/DataList/useCrudRef.ts"
import tool from "@/utils/tool"
import contactApi from "@/api/system/contact"
import abbrApi from "@/api/system/abbreviation"
import dictApi from "@/api/system/dict"
//// 1. 处理快速新增单位
const contactFormOptions = ref(
tool.renameKeyInArray(
contactColumnOption.filter((it) => it.dataIndex !== "id"),
"commonRules",
"rules"
)
)
const contactFormData = ref({})
const handleContactFormSubmit = async (data, done) => {
done(true)
try {
const res = await contactApi.save(data)
// 更新当前select的选项
const newInfo = {
label: res.data.name,
value: res.data.name,
disabled: false,
indeterminate: false
}
dictList.value["entrust_unit"].push(newInfo)
dictList.value["test_unit"].push(newInfo)
dictList.value["dev_unit"].push(newInfo)
// 清空当前数据
contactFormData.value = {}
Notification.success("添加成功,请回到输入框进行选择")
} catch (err) {
Notification.error("请求错误,请重试或在数据管理页面添加")
} finally {
done(false)
}
}
//// 2. 处理快速新增缩略语
const abbrFormOptions = ref(
tool.renameKeyInArray(
abbrColumnOption.filter((it) => it.dataIndex !== "id"),
"commonRules",
"rules"
)
)
const abbrFormData = ref({})
const handleAbbrFormSubmit = async (data, done) => {
done(true)
try {
const res = await abbrApi.save(data)
// 更新当前select的选项
const newInfo = {
label: res.data.title,
value: res.data.title,
disabled: false,
indeterminate: false
}
dictList.value["abbreviation"].push(newInfo)
// 清空当前数据
abbrFormData.value = {}
Notification.success("添加成功,请回到输入框进行选择")
} catch (err) {
Notification.error("请求错误,请重试或在数据管理页面添加")
} finally {
done(false)
}
}
//// 3. 处理快速依据标准
const { columns: dictColumnOptions } = useDictItemCrud()
const initStdFormData = {
status: "1",
code: "standard",
sort: 1
}
const stdFormData = ref(initStdFormData)
const stdFormOptions = computed(() => {
const options = tool.renameKeyInArray(
dictColumnOptions.value.filter(
(it) => it.dataIndex !== "id" && it.dataIndex !== "update_datetime" && it.dataIndex !== "key"
),
"commonRules",
"rules"
)
return options.map((it) => {
if (it.dataIndex === "doc_name") {
return {
...it,
rules: [{ required: true, message: "文档名称必填" }]
}
}
if (it.dataIndex === "publish_date") {
return {
...it,
rules: [{ required: true, message: "发布日期必填" }]
}
}
if (it.dataIndex === "source") {
return {
...it,
rules: [{ required: true, message: "来源机构必填" }]
}
}
return it
})
})
const handleStdFormSubmit = async (data, done) => {
done(true)
try {
const res = await dictApi.createDictItemStdFast(data)
// 更新当前select的选项
const newInfo = {
label: res.data.doc_name,
value: res.data.key,
disabled: false,
indeterminate: false
}
dictList.value["standard"].push(newInfo)
// 清空当前数据
stdFormData.value = initStdFormData
Notification.success("添加成功,请回到输入框进行选择")
} catch (err) {
Notification.error("请求错误,请重试或在数据管理页面添加")
} finally {
done(false)
}
}
// 改动2结束 - end
const props = defineProps({
component: Object,
@@ -159,8 +368,9 @@ const dictList = inject("dictList")
const formLoading = inject("formLoading")
const columns = inject("columns")
const getColumnService = inject("getColumnService")
const rv = async (ev, value = "") =>
const rv = async (ev, value = "") => {
await runEvent(props.component, ev, { formModel, getColumnService, columns }, value)
}
const index = props.customField ?? props.component.dataIndex
const dictIndex = index.match(/^(\w+\.)\d+\./)
@@ -172,6 +382,38 @@ const loading = ref(false)
const optionMap = ref({})
const keyword = ref("")
// 改动1新增按钮处理
const createItem = ref("") // 新增string
const createLoading = ref(false) // 新增loading状态
const handleCreteSubmit = async (onCreate) => {
// 判断是否为空
if (!createItem.value.trim()) {
Message.error("请填写新增内容")
return
}
createLoading.value = true
try {
const code = await onCreate(createItem.value)
// 处理回显内容-更新当前select的选项
const optionList = dictList.value[code]
const new_dict_item = {
label: createItem.value,
value: (optionList.length + 1).toString(),
disabled: false,
indeterminate: false
}
optionList.push(new_dict_item)
} catch (err) {
// 弹出错误
Message.error("新增出错")
} finally {
createItem.value = ""
createLoading.value = false
Notification.success("新增成功,请重新选择新增内容")
}
}
// 改动1结束
watch(
() => get(formModel.value, index),
(vl) => (value.value = vl)
@@ -271,6 +513,7 @@ const handlePage = async (page) => {
loading.value = false
}
// 搜索当前字典内容
const handlerFallback = (key) => {
return optionMap.value[key] || key
}

View File

@@ -11,7 +11,7 @@
:allow-clear="props.component.allowClear ?? true"
:disabled="props.component.disabled"
:readonly="props.component.readonly"
:auto-size="props.component.autoSize"
:auto-size="props.component.autoSize || true"
:error="props.component.error"
:placeholder="props.component.placeholder ?? `请输入${props.component.title}`"
:max-length="props.component.maxLength"

View File

@@ -24,6 +24,7 @@ app.use(ArcoVueIcon)
app.use(router)
app.use(pinia)
app.use(globalComponents)
// 使用服务端请求数据管理库
import { VueQueryPlugin } from "@tanstack/vue-query"
app.use(VueQueryPlugin)

View File

@@ -13,3 +13,22 @@ body {
--border-radius-medium: 0px;
--border-radius-large: 0px;
}
// 覆盖arco表单行间距为3px原来为20px
.arco-form-item {
display: flex;
align-items: flex-start;
justify-content: flex-start;
width: 100%;
margin-bottom: 5px;
}
// 覆盖card组件actions的margin-top原来为20px
.arco-card-actions{
margin-top: 0px !important;
}
// 覆盖card组件padding原来为16px
.arco-card-body{
padding: 8px !important;
}

View File

@@ -105,4 +105,7 @@ defineOptions({
.top-box {
font-size: 2rem;
}
:deep(.arco-form-item) {
margin-bottom: 20px; /* 覆盖默认样式 */
}
</style>

View File

@@ -51,7 +51,6 @@ const crudOptions = reactive({
// 是否显示操作列
operationColumn: true,
operationWidth: 200,
showTools: false,
// 设置列表数据API
api: userApi.getPageList,
// 设置新增接口-show为true则显示按钮

View File

@@ -0,0 +1,19 @@
export const columnsOptions = [
{ title: "ID", dataIndex: "id", addDisplay: false, editDisplay: false, width: 50, hide: true },
{
title: "缩略语",
align: "center",
width: 200,
dataIndex: "title",
search: true,
commonRules: [{ required: true, message: "缩略语必填" }]
},
{
title: "全称",
align: "center",
dataIndex: "des",
search: true,
ellipsis: true,
commonRules: [{ required: true, message: "全称和描述必填" }]
}
]

View File

@@ -10,6 +10,7 @@
<script lang="jsx" setup>
import { ref } from "vue"
import abbreviationApi from "@/api/system/abbreviation"
import { columnsOptions } from "./columnsOptions.ts"
const crudRef = ref()
const crudOptions = ref({
@@ -29,25 +30,7 @@ const crudOptions = ref({
crudRef.value.tableRef.selectAll(false)
}
})
const crudColumns = ref([
{ title: "ID", dataIndex: "id", addDisplay: false, editDisplay: false, width: 50, hide: true },
{
title: "缩略语",
align: "center",
width: 200,
dataIndex: "title",
search: true,
commonRules: [{ required: true, message: "缩略语必填" }]
},
{
title: "全称",
align: "center",
dataIndex: "des",
search: true,
ellipsis: true,
commonRules: [{ required: true, message: "全称和描述必填" }]
}
])
const crudColumns = ref(columnsOptions)
defineOptions({
name: "abbreviation"

View File

@@ -14,7 +14,6 @@ export default function useCrudRef(currentRow: Ref<{ id: number | string; name:
operationColumn: true,
operationWidth: 160,
operationColumnAlign: "center",
showTools: false,
beforeAdd: (form: any) => {
form.id = currentRow.value?.id
return true
@@ -95,21 +94,22 @@ export default function useCrudRef(currentRow: Ref<{ id: number | string; name:
dataIndex: "doc_name",
align: "center",
search: false,
placeholder: "如果不是标准则不填"
placeholder: "不是标准则不填"
},
{
title: "发布日期",
dataIndex: "publish_date",
align: "center",
search: false,
placeholder: "如果不是标准则不填"
placeholder: "不是标准则不填,该文档发布日期",
formType: "date"
},
{
title: "标准来源",
dataIndex: "source",
align: "center",
search: false,
placeholder: "如果不是标准则不填"
placeholder: "不是标准则不填,文档发布机构"
}
])

View File

@@ -28,7 +28,6 @@ export default function useDictCrud() {
searchColNumber: 4,
tablePagination: false,
operationColumn: true,
showTools: false,
afterDelete() {
crudRef.value.tableRef.selectAll(false)
}

View File

@@ -0,0 +1,34 @@
export const columnsOptions = [
{ title: "ID", dataIndex: "id", addDisplay: false, editDisplay: false, width: 50, hide: true },
{ title: "公司编号", align: "center", dataIndex: "key", search: true, width: 70, formType: "input-number" },
{
title: "名称",
align: "center",
dataIndex: "name",
search: true,
commonRules: [{ required: true, message: "名称必填" }]
},
{
title: "简称",
align: "center",
dataIndex: "refer_name",
width: 200,
search: true,
commonRules: [{ required: true, message: "简称必填" }]
},
{
title: "法人",
align: "center",
dataIndex: "entrust_person",
search: true,
width: 90,
commonRules: [{ required: true, message: "法人必填" }]
},
{
title: "地址",
align: "center",
dataIndex: "addr",
search: true,
commonRules: [{ required: true, message: "公司地址必填" }]
}
]

View File

@@ -10,6 +10,7 @@
<script setup>
import { ref } from "vue"
import contactApi from "@/api/system/contact"
import { columnsOptions } from "./crudColumns"
const crudRef = ref()
const crudOptions = ref({
@@ -25,45 +26,11 @@ const crudOptions = ref({
searchColNumber: 3,
tablePagination: false,
rowSelection: { showCheckedAll: true },
showTools: false,
afterDelete() {
crudRef.value.tableRef.selectAll(false)
}
})
const crudColumns = ref([
{ title: "ID", dataIndex: "id", addDisplay: false, editDisplay: false, width: 50, hide: true },
{ title: "公司编号", align: "center", dataIndex: "key", search: true, width: 70, formType: "input-number" },
{
title: "名称",
align: "center",
dataIndex: "name",
search: true,
commonRules: [{ required: true, message: "名称必填" }]
},
{
title: "简称",
align: "center",
dataIndex: "refer_name",
width: 200,
search: true,
commonRules: [{ required: true, message: "简称必填" }]
},
{
title: "法人",
align: "center",
dataIndex: "entrust_person",
search: true,
width: 90,
commonRules: [{ required: true, message: "法人必填" }]
},
{
title: "地址",
align: "center",
dataIndex: "addr",
search: true,
commonRules: [{ required: true, message: "公司地址必填" }]
}
])
const crudColumns = ref(columnsOptions)
</script>
<style lang="less" scoped></style>

View File

@@ -8,7 +8,10 @@
<img src="@/assets/img/wxwx-logo.svg" width="45" /><span>{{ $title }}</span>
</div>
<div class="slogan flex justify-end">
<span class="font-extrabold bg-clip-text text-transparent bg-gradient-to-r from-blue-500 to-purple-600">---- 为测评服务打造测评高地</span>
<span
class="font-extrabold bg-clip-text text-transparent bg-gradient-to-r from-blue-500 to-purple-600"
>---- 为测评服务打造测评高地</span
>
</div>
</div>
@@ -228,4 +231,8 @@ const handleSubmit = async ({ values, errors }) => {
background: #f3ce2b;
}
}
:deep(.arco-form-item) {
margin-bottom: 20px; /* 覆盖默认样式 */
}
</style>

View File

@@ -53,7 +53,6 @@ const crudOptions = ref({
api: logApi.getLoginLogs,
edit: { api: editClick, text: "查看操作日志信息", show: false },
showIndex: false,
showTools: false,
pageLayout: "fixed",
tablePagination: false,
operationColumn: true,

View File

@@ -29,7 +29,6 @@ const crudOptions = reactive({
api: operationApi.getOperationsLogs,
showIndex: false,
pageLayout: "fixed",
showTools: false,
tablePagination: false,
bordered: { wrapper: true, cell: true },
afterDelete(response) {

View File

@@ -53,7 +53,6 @@ const crudOptions = ref({
api: logApi.getOperations,
edit: { api: editClick, text: "查看操作日志信息", show: false },
showIndex: false,
showTools: false,
pageLayout: "fixed",
tablePagination: false,
operationColumn: true,

View File

@@ -137,7 +137,6 @@ const crudOptions = ref({
projectId: route.query.id,
key: route.query.key
},
showTools: false, // 不显示工具栏
operationColumn: true,
operationColumnAlign: "center", // 操作列居中
isDbClickEdit: false, // 双击不编辑当前列

View File

@@ -124,7 +124,6 @@ const crudOptions = ref({
return tableData
},
showIndex: false,
showTools: false,
operationColumnAlign: "center",
rowSelection: { showCheckedAll: true },
searchColNumber: 3,

View File

@@ -48,7 +48,6 @@ export default function (crudRef: Ref<InstanceType<typeof MaCrud>>) {
add: { show: true, api: testDemandApi.save, text: "新增测试项" },
edit: { show: true, api: testDemandApi.update, text: "修改测试项" },
delete: { show: true, api: testDemandApi.delete },
showTools: false,
beforeOpenAdd: function () {
// 1.新增则将form的content数据变为undifined以便判断
beforeFormContent = undefined

View File

@@ -68,7 +68,6 @@ export default function (crudRef: Ref<InstanceType<typeof MaCrud>>) {
formOption: {
width: 1200
},
showTools: false
})
return crudOptions
}

View File

@@ -54,7 +54,6 @@ export default function (crudRef: Ref<InstanceType<typeof MaCrud>>) {
},
operationWidth: 500,
showIndex: false,
showTools: false,
rowSelection: { showCheckedAll: true },
searchColNumber: 3,
tablePagination: false,

View File

@@ -106,7 +106,6 @@ export default function (crudRef: Ref<InstanceType<typeof MaCrud>>) {
testDemand: testDemandNumber
},
showIndex: false,
showTools: false,
rowSelection: { showCheckedAll: true },
searchColNumber: 3,
tablePagination: false,

View File

@@ -98,7 +98,6 @@ const useCrudOption = () => {
afterDelete(response: any) {
crudRef.value.tableRef.selectAll(false)
},
showTools: false,
operationColumn: true,
operationColumnWidth: 180,
operationColumnAlign: "center",

View File

@@ -2,6 +2,7 @@ import { ref } from "vue"
import { validateBlank, validateWindowFileNameInput } from "@/utils/extensions/arcoValidator"
import textInfo from "@/config/textInfo"
import projectApi from "@/api/testmanage/project"
import dictApi from "@/api/system/dict"
const useCrudInit = function () {
const crudRef = ref()
@@ -16,7 +17,6 @@ const useCrudInit = function () {
operationColumn: true,
operationWidth: 500,
showIndex: false,
showTools: false,
operationColumnWidth: 280, // 操作列宽度
operationColumnAlign: "center", // 操作列对齐方式
afterDelete(response: any) {
@@ -225,6 +225,14 @@ const useCrudInit = function () {
hide: true,
search: false,
formType: "select",
allowCreate: true,
createInfo: {
title: "运行环境"
},
onCreate: async (value: any) => {
await dictApi.createDictItemFast({ code: "runtime", title: value })
return "runtime"
},
dict: { name: "runtime", props: { label: "title", value: "key" } }
},
{
@@ -233,6 +241,8 @@ const useCrudInit = function () {
hide: true,
search: true,
formType: "select",
// 多选最大标签数量
maxTagCount: 7,
multiple: true,
dict: { url: "system/user/list", props: { label: "name", value: "name" }, translation: true },
commonRules: [{ required: true, message: "成员至少选择一个" }]
@@ -261,12 +271,24 @@ const useCrudInit = function () {
search: false,
formType: "select",
allowCreate: true,
createInfo: {
title: "开发环境"
},
onCreate: async (value: any) => {
await dictApi.createDictItemFast({ code: "devplant", title: value })
return "devplant"
},
dict: { name: "devplant", props: { label: "title", value: "key" } }
},
{
title: "缩略语",
dataIndex: "abbreviation",
hide: true,
// 快速新增缩略语内容
allowAbbrNew: true,
abbrNewInfo: {
title: "新增缩略语"
},
search: false,
formType: "select",
multiple: true,
@@ -339,6 +361,7 @@ const useCrudInit = function () {
title: "编程语言",
dataIndex: "language",
addDefaultValue: ["1"],
maxTagCount: 4,
commonRules: [{ required: true, message: "请至少选择一个" }],
hide: true,
formType: "select",
@@ -349,16 +372,27 @@ const useCrudInit = function () {
title: "依据标准",
dataIndex: "standard",
addDefaultValue: ["1", "2", "3", "4", "9"],
maxTagCount: 20,
commonRules: [{ required: true, message: "请至少选择一个" }],
hide: true,
multiple: true,
formType: "select",
dict: { name: "standard", props: { label: "title", value: "key" } }
dict: { name: "standard", props: { label: "title", value: "key" } },
// 新增select选项
allowStd: true,
stdInfo: {
title: "新增标准"
}
},
{
title: "单位",
dataIndex: "entrust_unit",
hide: true,
// 快速新增单位内容
allowNew: true,
newInfo: {
title: "新增单位信息"
},
commonRules: [{ required: true, message: "单位必选" }],
formType: "select",
dict: { url: "system/contact/index", props: { label: "name", value: "name" }, translation: true }
@@ -393,6 +427,11 @@ const useCrudInit = function () {
{
title: "单位",
dataIndex: "dev_unit",
// 快速新增单位内容
allowNew: true,
newInfo: {
title: "新增单位信息"
},
hide: true,
commonRules: [{ required: true, message: "单位必选" }],
formType: "select",
@@ -429,6 +468,11 @@ const useCrudInit = function () {
title: "单位",
dataIndex: "test_unit",
hide: true,
// 快速新增单位内容
allowNew: true,
newInfo: {
title: "新增单位信息"
},
addDefaultValue: textInfo.testUnitAddDefaultText,
commonRules: [{ required: true, message: "单位必选" }],
formType: "select",

View File

@@ -109,7 +109,7 @@
</div>
</template>
<script lang="jsx" setup>
<script setup lang="jsx">
import { ref } from "vue"
import { useRouter } from "vue-router"
import preview from "./cpns/preview.vue"