|
@@ -1,8 +1,8 @@
|
|
|
<template>
|
|
|
<a-modal
|
|
|
- :width="800"
|
|
|
+ :width="400"
|
|
|
v-model:visible="visible"
|
|
|
- title="title"
|
|
|
+ :title="title"
|
|
|
:confirm-loading="confirmLoading"
|
|
|
@ok="handleOk"
|
|
|
ok-text="提交"
|
|
@@ -10,30 +10,29 @@
|
|
|
:keyboard="false"
|
|
|
:mask-closable="false"
|
|
|
>
|
|
|
- <a-form autocomplete="off">
|
|
|
- <a-divider orientation="left">基础信息</a-divider>
|
|
|
+ <a-form :model="dataModel" autocomplete="off">
|
|
|
<a-row :gutter="24">
|
|
|
- <a-col :span="8">
|
|
|
+ <a-col :span="24">
|
|
|
<a-form-item label="标签名称" :label-col="{span:6}" name="labelName" v-bind="validateInfos.labelName">
|
|
|
<a-input v-model:value="dataModel.labelName" placeholder=""/>
|
|
|
</a-form-item>
|
|
|
</a-col>
|
|
|
</a-row>
|
|
|
+<!-- <a-row :gutter="24">-->
|
|
|
+<!-- <a-col :span="24">-->
|
|
|
+<!-- <a-form-item label="标签类型" :label-col="{span:6}" name="userType" v-bind="validateInfos.labelType">-->
|
|
|
+<!-- <a-select-->
|
|
|
+<!-- ref="select" disabled-->
|
|
|
+<!-- v-model:value="dataModel.labelType"-->
|
|
|
+<!-- :options="labelTypeList"-->
|
|
|
+<!-- :field-names="{label:'name',value:'value'}"-->
|
|
|
+<!-- >-->
|
|
|
+<!-- </a-select>-->
|
|
|
+<!-- </a-form-item>-->
|
|
|
+<!-- </a-col>-->
|
|
|
+<!-- </a-row>-->
|
|
|
<a-row :gutter="24">
|
|
|
- <a-col :span="8">
|
|
|
- <a-form-item label="标签类型" :label-col="{span:6}" name="userType" v-bind="validateInfos.labelType">
|
|
|
- <a-select
|
|
|
- ref="select"
|
|
|
- v-model:value="dataModel.labelType"
|
|
|
- :options="labelTypeList"
|
|
|
- :field-names="{label:'name',value:'value'}"
|
|
|
- >
|
|
|
- </a-select>
|
|
|
- </a-form-item>
|
|
|
- </a-col>
|
|
|
- </a-row>
|
|
|
- <a-row :gutter="24">
|
|
|
- <a-col :span="8">
|
|
|
+ <a-col :span="24">
|
|
|
<a-form-item label="排序号" :label-col="{span:6}" name="sortNo" v-bind="validateInfos.sortNo">
|
|
|
<a-input v-model:value="dataModel.sortNo" placeholder=""/>
|
|
|
</a-form-item>
|
|
@@ -43,26 +42,22 @@
|
|
|
</a-modal>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
-import {defineComponent, reactive, ref} from "vue";
|
|
|
+import {defineComponent, reactive, ref, toRefs} from "vue";
|
|
|
import {getLabelByID, saveLabel,} from "@/api/baseSettings/label";
|
|
|
import {Form} from "ant-design-vue";
|
|
|
import {getSysDictionaryList} from "@/api/system/dictionary";
|
|
|
-
|
|
|
+interface FormState {
|
|
|
+ dataModel: any;
|
|
|
+}
|
|
|
export default defineComponent({
|
|
|
- props: {
|
|
|
- loadData: {
|
|
|
- type: Function,
|
|
|
- default: null
|
|
|
- }
|
|
|
- },
|
|
|
- setup(props) {
|
|
|
+ name: 'editLabel',
|
|
|
+ props:{},
|
|
|
+ setup(props,context) {
|
|
|
const visible = ref<boolean>(false);
|
|
|
const confirmLoading = ref<boolean>(false);
|
|
|
const useForm = Form.useForm;
|
|
|
- const formState = reactive({
|
|
|
- loading: false,
|
|
|
- });
|
|
|
- const dataModel = ref({labelID: '', labelName: '', labelType: '', bigType: '', sortNo: ''});
|
|
|
+
|
|
|
+ const formState = reactive<FormState>({dataModel: {}});
|
|
|
const bigType = ref();
|
|
|
const labelTypeList = ref([]);
|
|
|
const title = ref('');
|
|
@@ -88,24 +83,25 @@ export default defineComponent({
|
|
|
]
|
|
|
});
|
|
|
|
|
|
- const {validate, validateInfos} = useForm(dataModel, rulesRef);
|
|
|
+ const {validate, validateInfos} = useForm(formState.dataModel, rulesRef);
|
|
|
|
|
|
- const show = (id: any, bigType: any, modelTitle: any) => {
|
|
|
+ const show = (id: any, type: any, modelTitle: any) => {
|
|
|
getLabelTypeList();
|
|
|
|
|
|
title.value = modelTitle;
|
|
|
- dataModel.value.labelID = id;
|
|
|
- bigType.value = bigType;
|
|
|
+ formState.dataModel.labelID = id;
|
|
|
+ bigType.value = type;
|
|
|
loadData();
|
|
|
visible.value = true;
|
|
|
};
|
|
|
|
|
|
const handleOk = () => {
|
|
|
validate().then(() => {
|
|
|
- saveLabel(dataModel.value).then(result => {
|
|
|
+ saveLabel(formState.dataModel).then(result => {
|
|
|
if (result) {
|
|
|
visible.value = false;
|
|
|
- props.loadData();
|
|
|
+ console.log(props)
|
|
|
+ context.emit("callBack")
|
|
|
}
|
|
|
});
|
|
|
});
|
|
@@ -116,9 +112,10 @@ export default defineComponent({
|
|
|
};
|
|
|
|
|
|
const loadData = () => {
|
|
|
- getLabelByID(dataModel.value.labelID).then((result: any) => {
|
|
|
- dataModel.value = result;
|
|
|
- dataModel.value.bigType = bigType.value;
|
|
|
+ getLabelByID(formState.dataModel.labelID).then((result: any) => {
|
|
|
+ formState.dataModel = result;
|
|
|
+ formState.dataModel.bigType = bigType.value;
|
|
|
+ formState.dataModel.labelType = 2;
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -129,13 +126,13 @@ export default defineComponent({
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
- dataModel,
|
|
|
+ ...toRefs(formState),
|
|
|
+ title,
|
|
|
visible,
|
|
|
confirmLoading,
|
|
|
show,
|
|
|
handleOk,
|
|
|
handleCancel,
|
|
|
- formState,
|
|
|
validateInfos,
|
|
|
validate,
|
|
|
labelTypeList,
|