|
@@ -28,14 +28,16 @@
|
|
|
type="success"
|
|
|
:loading="submitLoading"
|
|
|
@click="dialogSubmit"
|
|
|
- >保存数据</el-button
|
|
|
>
|
|
|
+ 保存数据
|
|
|
+ </el-button>
|
|
|
<el-button
|
|
|
type="info"
|
|
|
style="margin-left: 50px"
|
|
|
@click="resetFormClick"
|
|
|
- >重置</el-button
|
|
|
>
|
|
|
+ 重置
|
|
|
+ </el-button>
|
|
|
</div>
|
|
|
<hc-card-item title="已配数据:">
|
|
|
<hc-table
|
|
@@ -45,9 +47,9 @@
|
|
|
:is-index="false"
|
|
|
>
|
|
|
<template #action="{ row }">
|
|
|
- <el-link type="danger" @click="rowDelClick(row)"
|
|
|
- >删除</el-link
|
|
|
- >
|
|
|
+ <el-link type="danger" @click="rowDelClick(row)">
|
|
|
+ 删除
|
|
|
+ </el-link>
|
|
|
</template>
|
|
|
</hc-table>
|
|
|
</hc-card-item>
|
|
@@ -55,10 +57,10 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { onMounted, ref, watch } from "vue";
|
|
|
-import { HcDelMsg } from "hc-vue3-ui";
|
|
|
-import { formValidate, getArrValue, getObjValue } from "js-fast-way";
|
|
|
-import mainApi from "~api/project/tree";
|
|
|
+import { onMounted, ref, watch } from 'vue'
|
|
|
+import { HcDelMsg } from 'hc-vue3-ui'
|
|
|
+import { formValidate, getArrValue, getObjValue } from 'js-fast-way'
|
|
|
+import mainApi from '~api/project/tree'
|
|
|
|
|
|
const props = defineProps({
|
|
|
info: {
|
|
@@ -67,110 +69,111 @@ const props = defineProps({
|
|
|
},
|
|
|
type: {
|
|
|
type: [String, Number],
|
|
|
- default: "", //默认没有,独立表单库类型为2
|
|
|
+ default: '', //默认没有,独立表单库类型为2
|
|
|
},
|
|
|
-});
|
|
|
+})
|
|
|
|
|
|
//事件
|
|
|
-const emit = defineEmits(["finish"]);
|
|
|
+const emit = defineEmits(['finish'])
|
|
|
|
|
|
//监听数据
|
|
|
-const dataInfo = ref(props.info);
|
|
|
-const type = ref(props.type);
|
|
|
+const dataInfo = ref(props.info)
|
|
|
+const type = ref(props.type)
|
|
|
watch(
|
|
|
() => [props.info, props.type],
|
|
|
([data, tpe]) => {
|
|
|
- dataInfo.value = getObjValue(data);
|
|
|
+ dataInfo.value = getObjValue(data)
|
|
|
|
|
|
- type.value = tpe;
|
|
|
+ type.value = tpe
|
|
|
},
|
|
|
- { immediate: true, deep: true }
|
|
|
-);
|
|
|
+ { immediate: true, deep: true },
|
|
|
+)
|
|
|
|
|
|
//渲染完成
|
|
|
onMounted(() => {
|
|
|
- formModel.value = {};
|
|
|
- getSigList();
|
|
|
-});
|
|
|
+ formModel.value = {}
|
|
|
+ getSigList()
|
|
|
+})
|
|
|
|
|
|
//基础表单
|
|
|
-const formRef = ref(null);
|
|
|
-const formModel = ref({});
|
|
|
+const formRef = ref(null)
|
|
|
+const formModel = ref({})
|
|
|
const formRules = {
|
|
|
- colName: { required: true, trigger: "change", message: "请先获取元素坐标" },
|
|
|
- textId: { required: true, trigger: "change", message: "请填写默认信息" },
|
|
|
-};
|
|
|
+ colName: { required: true, trigger: 'change', message: '请先获取元素坐标' },
|
|
|
+ textId: { required: true, trigger: 'change', message: '请填写默认信息' },
|
|
|
+}
|
|
|
|
|
|
//数据表格
|
|
|
const tableColumn = [
|
|
|
- { key: "colName", name: "元素位置" },
|
|
|
- { key: "sigRoleName", name: "默认值" },
|
|
|
- { key: "action", name: "操作", align: "center", width: 100 },
|
|
|
-];
|
|
|
-const tableData = ref([]);
|
|
|
+ { key: 'colName', name: '元素位置' },
|
|
|
+ { key: 'sigRoleName', name: '默认值' },
|
|
|
+ { key: 'action', name: '操作', align: 'center', width: 100 },
|
|
|
+]
|
|
|
+const tableData = ref([])
|
|
|
//获取数据
|
|
|
const getSigList = async () => {
|
|
|
- const { pkeyId, primaryKeyId } = dataInfo.value;
|
|
|
+ const { pkeyId, primaryKeyId } = dataInfo.value
|
|
|
const { data } = await mainApi.getSigList({
|
|
|
current: 0,
|
|
|
size: 99999,
|
|
|
type: 4,
|
|
|
tabId: type.value == 2 ? primaryKeyId : pkeyId,
|
|
|
- });
|
|
|
- tableData.value = getArrValue(data?.records);
|
|
|
-};
|
|
|
+ })
|
|
|
+ tableData.value = getArrValue(data?.records)
|
|
|
+}
|
|
|
|
|
|
//删除数据
|
|
|
const rowDelClick = (row) => {
|
|
|
HcDelMsg(async (resolve) => {
|
|
|
- const { pkeyId, primaryKeyId } = dataInfo.value;
|
|
|
+ const { pkeyId, primaryKeyId } = dataInfo.value
|
|
|
const { isRes } = await mainApi.remove(
|
|
|
row.id,
|
|
|
- type.value == 2 ? primaryKeyId : pkeyId
|
|
|
- );
|
|
|
- resolve(); //关闭弹窗的回调
|
|
|
- if (!isRes) return;
|
|
|
- getSigList().then();
|
|
|
- });
|
|
|
-};
|
|
|
+ type.value == 2 ? primaryKeyId : pkeyId,
|
|
|
+ )
|
|
|
+ resolve() //关闭弹窗的回调
|
|
|
+ if (!isRes) return
|
|
|
+ emit('finish')
|
|
|
+ getSigList().then()
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
//提交
|
|
|
-const submitLoading = ref(false);
|
|
|
+const submitLoading = ref(false)
|
|
|
const dialogSubmit = async () => {
|
|
|
- const isForm = await formValidate(formRef.value);
|
|
|
- if (!isForm) return false;
|
|
|
- submitLoading.value = true;
|
|
|
- const { isRes } = await mainApi.saveDdefual(formModel.value);
|
|
|
- submitLoading.value = false;
|
|
|
- if (!isRes) return;
|
|
|
- window.$message.success("操作成功");
|
|
|
- emit("finish");
|
|
|
- getSigList().then();
|
|
|
-};
|
|
|
+ const isForm = await formValidate(formRef.value)
|
|
|
+ if (!isForm) return false
|
|
|
+ submitLoading.value = true
|
|
|
+ const { isRes } = await mainApi.saveDdefual(formModel.value)
|
|
|
+ submitLoading.value = false
|
|
|
+ if (!isRes) return
|
|
|
+ window.$message.success('操作成功')
|
|
|
+ emit('finish')
|
|
|
+ getSigList().then()
|
|
|
+}
|
|
|
|
|
|
//重置表单
|
|
|
const resetFormClick = () => {
|
|
|
- formModel.value = { type: "4" };
|
|
|
-};
|
|
|
+ formModel.value = { type: '4' }
|
|
|
+}
|
|
|
|
|
|
//设置dom数据
|
|
|
const setDomData = (item) => {
|
|
|
- const { pkeyId, primaryKeyId } = dataInfo.value;
|
|
|
+ const { pkeyId, primaryKeyId } = dataInfo.value
|
|
|
formModel.value = {
|
|
|
- type: "4",
|
|
|
+ type: '4',
|
|
|
colName: item.text,
|
|
|
colKey: item.key,
|
|
|
tableId: type.value == 2 ? primaryKeyId : pkeyId,
|
|
|
trIndex: item.tr,
|
|
|
tdIndex: item.td,
|
|
|
- textId: item.def || "",
|
|
|
- };
|
|
|
-};
|
|
|
+ textId: item.def || '',
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
//导出函数
|
|
|
defineExpose({
|
|
|
setDomData,
|
|
|
-});
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|