更新
This commit is contained in:
@@ -13,7 +13,10 @@ const formRules = ref({
|
|||||||
auxiliary_color: [
|
auxiliary_color: [
|
||||||
{ required: true, message: "请选择辅助色值", trigger: "change" }
|
{ required: true, message: "请选择辅助色值", trigger: "change" }
|
||||||
],
|
],
|
||||||
|
file_url: [{ required: true, message: "请输入文件地址", trigger: "blur" }],
|
||||||
|
times: [
|
||||||
|
{ required: true, message: "请选择有效期", trigger: "change" }
|
||||||
|
],
|
||||||
theme_name: [{ required: true, message: "请输入主题名称", trigger: "blur" }],
|
theme_name: [{ required: true, message: "请输入主题名称", trigger: "blur" }],
|
||||||
});
|
});
|
||||||
const props = defineProps(["formInline"]);
|
const props = defineProps(["formInline"]);
|
||||||
@@ -25,7 +28,8 @@ const newFormInline = ref(
|
|||||||
theme_color: "",
|
theme_color: "",
|
||||||
auxiliary_color: "",
|
auxiliary_color: "",
|
||||||
file_url: "",
|
file_url: "",
|
||||||
is_active: 0
|
is_active: 0,
|
||||||
|
times: []
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
function getRef() {
|
function getRef() {
|
||||||
@@ -34,10 +38,10 @@ function getRef() {
|
|||||||
function chanageEditorValue(val) {
|
function chanageEditorValue(val) {
|
||||||
newFormInline.value.content = val
|
newFormInline.value.content = val
|
||||||
}
|
}
|
||||||
function onExceed () {
|
function onExceed() {
|
||||||
message("最多上传1个文件,请先删除在上传");
|
message("最多上传1个文件,请先删除在上传");
|
||||||
};
|
};
|
||||||
function handleFileSuccess ({ data, code }, file, fileList) {
|
function handleFileSuccess({ data, code }, file, fileList) {
|
||||||
// console.log(file)
|
// console.log(file)
|
||||||
// console.log(fileList)
|
// console.log(fileList)
|
||||||
// debugger
|
// debugger
|
||||||
@@ -65,20 +69,12 @@ defineExpose({ getRef });
|
|||||||
<el-color-picker v-model="newFormInline.auxiliary_color"></el-color-picker>
|
<el-color-picker v-model="newFormInline.auxiliary_color"></el-color-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="文件地址" prop="file_url">
|
<el-form-item label="文件地址" prop="file_url">
|
||||||
<el-upload
|
<el-input v-model="newFormInline.file_url" placeholder="请输入文件地址"></el-input>
|
||||||
class="upload-demo"
|
</el-form-item>
|
||||||
drag
|
<el-form-item label="有效期" prop="times">
|
||||||
:limit="1"
|
<el-date-picker format="YYYY-MM-DD" value-format="YYYY-MM-DD" v-model="newFormInline.times" type="daterange"
|
||||||
name="files"
|
range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
|
||||||
accept=".zip"
|
</el-date-picker>
|
||||||
:headers="{ Authorization: getToken().accessToken }"
|
|
||||||
action="/adminapi/UploadFile/file_upload"
|
|
||||||
:on-exceed="onExceed"
|
|
||||||
:on-success="handleFileSuccess"
|
|
||||||
>
|
|
||||||
<i class="el-icon-upload"></i>
|
|
||||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
|
||||||
</el-upload>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="使用状态" prop="is_active">
|
<el-form-item label="使用状态" prop="is_active">
|
||||||
<el-radio-group v-model="newFormInline.is_active">
|
<el-radio-group v-model="newFormInline.is_active">
|
||||||
|
|||||||
@@ -109,7 +109,8 @@ export function useData() {
|
|||||||
theme_color: rowData?.theme_color ?? "",
|
theme_color: rowData?.theme_color ?? "",
|
||||||
auxiliary_color: rowData?.auxiliary_color ?? "",
|
auxiliary_color: rowData?.auxiliary_color ?? "",
|
||||||
file_url: rowData?.file_url ?? "",
|
file_url: rowData?.file_url ?? "",
|
||||||
is_active: rowData?.is_active ?? ""
|
is_active: rowData?.is_active ?? "",
|
||||||
|
times: [rowData?.begin_time ?? "", rowData?.end_time ?? ""]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
width: "40%",
|
width: "40%",
|
||||||
@@ -143,14 +144,15 @@ export function useData() {
|
|||||||
};
|
};
|
||||||
FormRef.validate(valid => {
|
FormRef.validate(valid => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
console.log("curData", curData);
|
let formData = { ...curData, begin_time: curData.times.length ? curData.times[0] : '', end_time: curData.times.length ? curData.times[1] : '' }
|
||||||
|
delete formData.times
|
||||||
// 表单规则校验通过
|
// 表单规则校验通过
|
||||||
if (title === "新增") {
|
if (title === "新增") {
|
||||||
// 实际开发先调用新增接口,再进行下面操作
|
// 实际开发先调用新增接口,再进行下面操作
|
||||||
saveData(curData);
|
saveData(formData);
|
||||||
} else {
|
} else {
|
||||||
// 实际开发先调用修改接口,再进行下面操作
|
// 实际开发先调用修改接口,再进行下面操作
|
||||||
updateData(curData);
|
updateData(formData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user