最新提交
This commit is contained in:
@@ -12,6 +12,17 @@ export class FragApi {
|
||||
params
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 根据用户填写新增文档片段
|
||||
* @returns 新增是否成功
|
||||
*/
|
||||
static add(data: IFragUpdateObject) {
|
||||
return request({
|
||||
url: "system/userField/add",
|
||||
method: "post",
|
||||
data
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 根据fragment的对象更新数据库
|
||||
* @returns 是否更新成功
|
||||
|
||||
@@ -57,8 +57,8 @@ const props = defineProps({
|
||||
type: [String, Array],
|
||||
// 如果要取消粘贴只粘贴文本,需要用户加格式请加上pastetext
|
||||
default:
|
||||
"code undo redo restoredraft | paste | bold | alignleft alignjustify indent formatpainter | \
|
||||
styleselect formatselect fontselect fontsizeselect | bullist numlist | subscript superscript removeformat"
|
||||
"code undo redo restoredraft | paste | bold | aligncenter alignleft alignjustify indent | \
|
||||
styleselect formatselect fontselect fontsizeselect | bullist numlist | removeformat"
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
>
|
||||
<template #extra>
|
||||
<a-space>
|
||||
<!-- 修改源码:新增复制该项新增 -->
|
||||
<a-tooltip content="复制该项添加" v-if="!(props.component.hideAdd ?? false)">
|
||||
<a-button
|
||||
@click.stop="addItem(item)"
|
||||
@@ -218,10 +219,12 @@ if (props.component.type == "table") {
|
||||
}
|
||||
|
||||
const addItem = async (data = {}) => {
|
||||
// 修改源码:深度复制
|
||||
let newData = cloneDeep(data)
|
||||
let index = formModel.value[props.component.dataIndex].length
|
||||
viewFormList.value[index] = cloneDeep(formList)
|
||||
rv("onAdd", { formList: viewFormList.value[index], data, index })
|
||||
formModel.value[props.component.dataIndex].push(data)
|
||||
rv("onAdd", { formList: viewFormList.value[index], newData, index }) // 修改源码:深度复制data->newData
|
||||
formModel.value[props.component.dataIndex].push(newData) // 修改源码:深度复制data->newData
|
||||
}
|
||||
|
||||
const deleteItem = async (index) => {
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
<script lang="jsx" setup>
|
||||
import { ref } from "vue"
|
||||
import { Message } from "@arco-design/web-vue"
|
||||
import abbreviationApi from "@/api/system/abbreviation"
|
||||
|
||||
const crudRef = ref()
|
||||
|
||||
111
cdTMP/src/views/testmanage/projFragment/hooks/crudOption.ts
Normal file
111
cdTMP/src/views/testmanage/projFragment/hooks/crudOption.ts
Normal file
@@ -0,0 +1,111 @@
|
||||
import { useRoute } from "vue-router"
|
||||
import { ref } from "vue"
|
||||
import { FragApi } from "@/api/system/fragment"
|
||||
import { ProductFileEnum } from "@/utils/enums/productTypes"
|
||||
import type { IDictData } from "@/utils/types/CommonType"
|
||||
import { IFragSearchCondition } from "@/api/system/types/fragmentTypes"
|
||||
|
||||
const useCrudOption = () => {
|
||||
// global
|
||||
const route = useRoute()
|
||||
const crudRef = ref()
|
||||
// 产品文档类型写死7种
|
||||
const productFileType: IDictData<ProductFileEnum>[] = Object.keys(ProductFileEnum).map((it, index) => ({
|
||||
label: ProductFileEnum[it],
|
||||
value: index + 1
|
||||
}))
|
||||
// crud-option
|
||||
const crudOptions = ref<object>({
|
||||
api: FragApi.getFragList,
|
||||
add: { show: true, api: FragApi.add },
|
||||
edit: { show: true, api: FragApi.update },
|
||||
delete: { show: true, api: FragApi.delete },
|
||||
// 新增需要项目id
|
||||
parameters: {
|
||||
projectId: route.params.projectId as string
|
||||
},
|
||||
beforeRequest: (params: IFragSearchCondition) => {
|
||||
// 添加项目id参数
|
||||
params.projectId = route.params.projectId as string
|
||||
},
|
||||
afterDelete(response: any) {
|
||||
crudRef.value.tableRef.selectAll(false)
|
||||
},
|
||||
showTools: false,
|
||||
operationColumn: true,
|
||||
operationColumnWidth: 180,
|
||||
operationColumnAlign: "center",
|
||||
bordered: { wrapper: true, cell: true },
|
||||
resizable: false, // 不允许调整列宽
|
||||
rowSelection: { showCheckedAll: true, checkStrictly: true },
|
||||
isDbClickEdit: false,
|
||||
searchColNumber: 2,
|
||||
formOption: {
|
||||
isFull: true,
|
||||
layout: [
|
||||
{
|
||||
formType: "grid",
|
||||
cols: [
|
||||
{ span: 12, formList: [{ dataIndex: "name" }] },
|
||||
{ span: 12, formList: [{ dataIndex: "belong_doc" }] }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
const crudColumns = ref<any[]>([
|
||||
{
|
||||
title: "ID",
|
||||
align: "center",
|
||||
width: 50,
|
||||
hide: true,
|
||||
dataIndex: "id",
|
||||
commonRules: [{ required: true, message: "ID必填" }],
|
||||
validateTrigger: "blur"
|
||||
},
|
||||
{
|
||||
title: "片段名称",
|
||||
align: "center",
|
||||
width: 180,
|
||||
dataIndex: "name",
|
||||
search: true,
|
||||
commonRules: [{ required: true, message: "片段名称必填" }],
|
||||
validateTrigger: "blur"
|
||||
},
|
||||
{
|
||||
title: "所属文档",
|
||||
align: "center",
|
||||
width: 100,
|
||||
dataIndex: "belong_doc",
|
||||
formType: "select",
|
||||
search: true,
|
||||
commonRules: [{ required: true, message: "所属文档必选" }],
|
||||
dict: { data: productFileType, translation: true }
|
||||
},
|
||||
{
|
||||
title: "替换片段",
|
||||
width: 100,
|
||||
align: "center",
|
||||
dataIndex: "is_main",
|
||||
addDisplay: false,
|
||||
editDisplay: false
|
||||
},
|
||||
{
|
||||
title: "内容",
|
||||
align: "center",
|
||||
dataIndex: "content",
|
||||
hide: true,
|
||||
formType: "editor",
|
||||
height: 550
|
||||
}
|
||||
])
|
||||
|
||||
return {
|
||||
crudRef,
|
||||
crudOptions,
|
||||
crudColumns,
|
||||
route
|
||||
}
|
||||
}
|
||||
|
||||
export default useCrudOption
|
||||
@@ -19,40 +19,32 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="tsx">
|
||||
import { computed, ComputedRef, ref } from "vue"
|
||||
import { useRoute } from "vue-router"
|
||||
import { computed, ComputedRef } from "vue"
|
||||
import PageHeader from "@/views/testmanage/components/PageHeader/index.vue"
|
||||
import useFetchData from "@/hooks/fetchData"
|
||||
// apis
|
||||
// apis - import
|
||||
import { FragApi } from "@/api/system/fragment"
|
||||
import projectApi from "@/api/testmanage/project"
|
||||
// types
|
||||
import { ProductFileEnum } from "@/utils/enums/productTypes"
|
||||
import type { IDictData } from "@/utils/types/CommonType"
|
||||
// types - import
|
||||
import type { IPageHeaderProps } from "../components/PageHeader/types"
|
||||
import type { IFragSearchCondition } from "@/api/system/types/fragmentTypes"
|
||||
import { Message } from "@arco-design/web-vue"
|
||||
|
||||
const route = useRoute()
|
||||
const crudRef = ref()
|
||||
// 产品文档类型写死7种
|
||||
const productFileType: IDictData<ProductFileEnum>[] = Object.keys(ProductFileEnum).map((it, index) => ({
|
||||
label: ProductFileEnum[it],
|
||||
value: index + 1
|
||||
}))
|
||||
// hook-获取单个项目信息
|
||||
// hooks-import
|
||||
import useFetchData from "@/hooks/fetchData"
|
||||
import useCrudOption from "./hooks/crudOption"
|
||||
// 1.hook-crudOptions
|
||||
const { crudRef, crudOptions, crudColumns, route } = useCrudOption()
|
||||
// 2.hook-获取单个项目信息
|
||||
const fetchData = async () => {
|
||||
return projectApi.getProjectById(route.params.projectId)
|
||||
}
|
||||
const { loadingData, isDataLoading } = useFetchData({}, fetchData)
|
||||
// 给头部组件的计算属性
|
||||
// 3.给头部组件的计算属性
|
||||
const headerData: ComputedRef<IPageHeaderProps> = computed(() => {
|
||||
return {
|
||||
title: loadingData.value.ident as string,
|
||||
name: loadingData.value.name as string
|
||||
}
|
||||
})
|
||||
// 在表格切换is_main属性
|
||||
// 4.noQuery - 请求头部数据
|
||||
const beforeSwitchChange = (record: any) => {
|
||||
return async function (newVal: boolean) {
|
||||
await FragApi.update(record.id, {
|
||||
@@ -63,86 +55,6 @@ const beforeSwitchChange = (record: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
// ma-crud配置
|
||||
const crudOptions = ref<object>({
|
||||
api: FragApi.getFragList,
|
||||
edit: { show: true, api: FragApi.update },
|
||||
delete: { show: true, api: FragApi.delete },
|
||||
beforeRequest: (params: IFragSearchCondition) => {
|
||||
// 添加项目id参数
|
||||
params.projectId = route.params.projectId as string
|
||||
},
|
||||
afterDelete(response: any) {
|
||||
crudRef.value.tableRef.selectAll(false)
|
||||
},
|
||||
showTools: false,
|
||||
operationColumn: true,
|
||||
operationColumnWidth: 120,
|
||||
operationColumnAlign: "center",
|
||||
bordered: { wrapper: true, cell: true },
|
||||
resizable: false, // 不允许调整列宽
|
||||
rowSelection: { showCheckedAll: true, checkStrictly: true },
|
||||
isDbClickEdit: false,
|
||||
searchColNumber: 2,
|
||||
formOption: {
|
||||
isFull: true,
|
||||
layout: [
|
||||
{
|
||||
formType: "grid",
|
||||
cols: [
|
||||
{ span: 12, formList: [{ dataIndex: "name" }] },
|
||||
{ span: 12, formList: [{ dataIndex: "belong_doc" }] }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
const crudColumns = ref<any[]>([
|
||||
{
|
||||
title: "ID",
|
||||
align: "center",
|
||||
width: 50,
|
||||
hide: true,
|
||||
dataIndex: "id",
|
||||
commonRules: [{ required: true, message: "ID必填" }],
|
||||
validateTrigger: "blur"
|
||||
},
|
||||
{
|
||||
title: "片段名称",
|
||||
align: "center",
|
||||
width: 120,
|
||||
dataIndex: "name",
|
||||
search: true,
|
||||
commonRules: [{ required: true, message: "片段名称必填" }],
|
||||
validateTrigger: "blur"
|
||||
},
|
||||
{
|
||||
title: "所属文档",
|
||||
align: "center",
|
||||
width: 100,
|
||||
dataIndex: "belong_doc",
|
||||
formType: "select",
|
||||
search: true,
|
||||
commonRules: [{ required: true, message: "所属文档必选" }],
|
||||
dict: { data: productFileType, translation: true }
|
||||
},
|
||||
{
|
||||
title: "替换片段",
|
||||
align: "center",
|
||||
dataIndex: "is_main",
|
||||
addDisplay: false,
|
||||
editDisplay: false
|
||||
},
|
||||
{
|
||||
title: "内容",
|
||||
align: "center",
|
||||
dataIndex: "content",
|
||||
hide: true,
|
||||
formType: "editor",
|
||||
height: 550
|
||||
}
|
||||
])
|
||||
|
||||
defineOptions({
|
||||
name: "projFragment"
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user