修改样式
This commit is contained in:
parent
7fe5dcf9af
commit
f65cbb8774
|
|
@ -83,6 +83,7 @@
|
||||||
</a-modal>
|
</a-modal>
|
||||||
<!-- 表单区域 -->
|
<!-- 表单区域 -->
|
||||||
<NuResourcesManagementModal ref="registerModal" @success="handleSuccess"></NuResourcesManagementModal>
|
<NuResourcesManagementModal ref="registerModal" @success="handleSuccess"></NuResourcesManagementModal>
|
||||||
|
<NuResourcesManagementDetailModal ref="registerDetailModal" @success="handleSuccess"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -94,6 +95,7 @@
|
||||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './NuResourcesManagement.api';
|
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './NuResourcesManagement.api';
|
||||||
import { downloadFile } from '/@/utils/common/renderUtils';
|
import { downloadFile } from '/@/utils/common/renderUtils';
|
||||||
import NuResourcesManagementModal from './components/NuResourcesManagementModal.vue'
|
import NuResourcesManagementModal from './components/NuResourcesManagementModal.vue'
|
||||||
|
import NuResourcesManagementDetailModal from './components/NuResourcesManagementDetailModal.vue'
|
||||||
import { useUserStore } from '/@/store/modules/user';
|
import { useUserStore } from '/@/store/modules/user';
|
||||||
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
|
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
|
||||||
import JSelectMultiple from '/@/components/Form/src/jeecg/components/JSelectMultiple.vue';
|
import JSelectMultiple from '/@/components/Form/src/jeecg/components/JSelectMultiple.vue';
|
||||||
|
|
@ -103,6 +105,7 @@
|
||||||
const queryParam = reactive<any>({});
|
const queryParam = reactive<any>({});
|
||||||
const toggleSearchStatus = ref<boolean>(false);
|
const toggleSearchStatus = ref<boolean>(false);
|
||||||
const registerModal = ref();
|
const registerModal = ref();
|
||||||
|
const registerDetailModal = ref();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
//注册table数据
|
//注册table数据
|
||||||
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||||
|
|
@ -180,15 +183,6 @@ const closeAudioModal = () => {
|
||||||
showAudioModal.value = false;
|
showAudioModal.value = false;
|
||||||
audioUrl.value = '';
|
audioUrl.value = '';
|
||||||
};
|
};
|
||||||
/**
|
|
||||||
* 高级查询事件
|
|
||||||
*/
|
|
||||||
function handleSuperQuery(params) {
|
|
||||||
Object.keys(params).map((k) => {
|
|
||||||
queryParam[k] = params[k];
|
|
||||||
});
|
|
||||||
searchQuery();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增事件
|
* 新增事件
|
||||||
|
|
@ -210,8 +204,8 @@ const closeAudioModal = () => {
|
||||||
* 详情
|
* 详情
|
||||||
*/
|
*/
|
||||||
function handleDetail(record: Recordable) {
|
function handleDetail(record: Recordable) {
|
||||||
registerModal.value.disableSubmit = true;
|
registerDetailModal.value.disableSubmit = true;
|
||||||
registerModal.value.edit(record);
|
registerDetailModal.value.edit(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,223 @@
|
||||||
|
<template>
|
||||||
|
<a-spin :spinning="confirmLoading">
|
||||||
|
<JFormContainer :disabled="disabled">
|
||||||
|
<template #detail>
|
||||||
|
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol" name="NuResourcesManagementForm">
|
||||||
|
<a-row>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item label="资源类型" v-bind="validateInfos.resourcesType" id="NuResourcesManagementForm-resourcesType" name="resourcesType">
|
||||||
|
<j-dict-select-tag v-model:value="formData.resourcesType" dictCode="resources_type" placeholder="请选择类型" @change="changeFileType" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item label="附件类型" v-bind="validateInfos.fileType" id="NuResourcesManagementForm-fileType" name="fileType">
|
||||||
|
<j-dict-select-tag v-model:value="formData.fileType" dictCode="file_type" placeholder="请选择附件类型" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item label="名称" v-bind="validateInfos.name" id="NuResourcesManagementForm-name" name="name">
|
||||||
|
<a-input v-model:value="formData.name" maxlength="20" show-count placeholder="请输入名称" ></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24" v-if="formData.fileType == 'image'">
|
||||||
|
<a-form-item label="默认图标" v-bind="validateInfos.filePath" id="NuResourcesManagementForm-filePath" name="filePath">
|
||||||
|
<img :src="getImgView(formData.filePath)" style="width:90px;height:90px;" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24" v-if="formData.fileType == 'image'">
|
||||||
|
<a-form-item label="焦点图标" v-bind="validateInfos.checkPicPath" id="NuResourcesManagementForm-checkPicPath" name="checkPicPath">
|
||||||
|
<img :src="getImgView(formData.checkPicPath)" style="width:90px;height:90px;" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24" v-if="formData.fileType == 'video'">
|
||||||
|
<a-form-item label="视频" v-bind="validateInfos.filePath" id="NuResourcesManagementForm-filePath" name="filePath">
|
||||||
|
<JUploadMp4 maxCount="1" bizPath="/zzbq" v-model:value="formData.filePath" fileType="mp4" :disabled="disabled"/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24" v-if="formData.fileType == 'audio'">
|
||||||
|
<a-form-item label="音频" v-bind="validateInfos.filePath" id="NuResourcesManagementForm-filePath" name="filePath">
|
||||||
|
<JUploadMp3 maxCount="1" bizPath="/zzbq" v-model:value="formData.filePath" fileType="mp3" :disabled="disabled"/>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24" v-if="formData.fileType == 'document'">
|
||||||
|
<a-form-item label="文档" v-bind="validateInfos.filePath" id="NuResourcesManagementForm-filePath" name="filePath">
|
||||||
|
<j-upload :fileMax="1" v-model:value="formData.filePath" ></j-upload>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24" hidden>
|
||||||
|
<a-form-item label="备注" v-bind="validateInfos.content" id="NuResourcesManagementForm-content" name="content">
|
||||||
|
<a-textarea v-model:value="formData.content" maxlength="50" show-count :rows="4" placeholder="请输入备注" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
</a-form>
|
||||||
|
</template>
|
||||||
|
</JFormContainer>
|
||||||
|
</a-spin>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted } from 'vue';
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
|
||||||
|
import JImageUpload from '/@/components/Form/src/jeecg/components/JImageUploadNoPreview.vue';
|
||||||
|
import JUpload from '/@/components/Form/src/jeecg/components/JUpload/JUpload.vue';
|
||||||
|
import JUploadMp3 from '/@/components/Form/src/jeecg/components/JUpload/JUploadMp3.vue';
|
||||||
|
import JUploadMp4 from '/@/components/Form/src/jeecg/components/JUpload/JUploadMp4.vue';
|
||||||
|
import { getValueType } from '/@/utils';
|
||||||
|
import { saveOrUpdate, queryUniqueCheck } from '../NuResourcesManagement.api';
|
||||||
|
import { Form } from 'ant-design-vue';
|
||||||
|
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
|
||||||
|
import { getFileAccessHttpUrl } from '/@/utils/common/compUtils';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
formDisabled: { type: Boolean, default: false },
|
||||||
|
formData: { type: Object, default: () => ({})},
|
||||||
|
formBpm: { type: Boolean, default: true }
|
||||||
|
});
|
||||||
|
const formRef = ref();
|
||||||
|
const useForm = Form.useForm;
|
||||||
|
const emit = defineEmits(['register', 'ok']);
|
||||||
|
const formData = reactive<Record<string, any>>({
|
||||||
|
id: '',
|
||||||
|
resourcesType: '',
|
||||||
|
fileType: '',
|
||||||
|
name: '',
|
||||||
|
filePath: '',
|
||||||
|
checkPicPath: '',
|
||||||
|
content: '',
|
||||||
|
});
|
||||||
|
const { createMessage } = useMessage();
|
||||||
|
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
|
||||||
|
const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } });
|
||||||
|
const confirmLoading = ref<boolean>(false);
|
||||||
|
//表单验证
|
||||||
|
const validatorRules = reactive({
|
||||||
|
});
|
||||||
|
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false });
|
||||||
|
|
||||||
|
// 表单禁用
|
||||||
|
const disabled = computed(()=>{
|
||||||
|
if(props.formBpm === true){
|
||||||
|
if(props.formData.disabled === false){
|
||||||
|
return false;
|
||||||
|
}else{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return props.formDisabled;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function getImgView(text) {
|
||||||
|
if (text && text.indexOf(',') > 0) {
|
||||||
|
text = text.substring(0, text.indexOf(','));
|
||||||
|
}
|
||||||
|
return getFileAccessHttpUrl(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeFileType(value) {
|
||||||
|
console.log("🚀 ~ changeFileType ~ value:", value)
|
||||||
|
if(value == '1'){
|
||||||
|
formData.fileType = 'image';
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
*/
|
||||||
|
function add() {
|
||||||
|
edit({});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
*/
|
||||||
|
function edit(record) {
|
||||||
|
nextTick(() => {
|
||||||
|
resetFields();
|
||||||
|
const tmpData = {};
|
||||||
|
Object.keys(formData).forEach((key) => {
|
||||||
|
if(record.hasOwnProperty(key)){
|
||||||
|
tmpData[key] = record[key]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
//赋值
|
||||||
|
Object.assign(formData, tmpData);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提交数据
|
||||||
|
*/
|
||||||
|
async function submitForm() {
|
||||||
|
try {
|
||||||
|
// 触发表单验证
|
||||||
|
await validate();
|
||||||
|
} catch ({ errorFields }) {
|
||||||
|
if (errorFields) {
|
||||||
|
const firstField = errorFields[0];
|
||||||
|
if (firstField) {
|
||||||
|
formRef.value.scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Promise.reject(errorFields);
|
||||||
|
}
|
||||||
|
confirmLoading.value = true;
|
||||||
|
const isUpdate = ref<boolean>(false);
|
||||||
|
//时间格式化
|
||||||
|
let model = formData;
|
||||||
|
if (model.id) {
|
||||||
|
isUpdate.value = true;
|
||||||
|
}
|
||||||
|
//循环数据
|
||||||
|
for (let data in model) {
|
||||||
|
//如果该数据是数组并且是字符串类型
|
||||||
|
if (model[data] instanceof Array) {
|
||||||
|
let valueType = getValueType(formRef.value.getProps, data);
|
||||||
|
//如果是字符串类型的需要变成以逗号分割的字符串
|
||||||
|
if (valueType === 'string') {
|
||||||
|
model[data] = model[data].join(',');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const check = await queryUniqueCheck(model);
|
||||||
|
console.log("🚀 ~ file: NuResourcesManagementForm.vue ~ line 171 ~ queryUniqueCheck ~ check:", check)
|
||||||
|
if(check.unique == 'true'){
|
||||||
|
|
||||||
|
}else if(check.unique == 'false'){
|
||||||
|
confirmLoading.value = false;
|
||||||
|
createMessage.warning(check.message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await saveOrUpdate(model, isUpdate.value)
|
||||||
|
.then((res) => {
|
||||||
|
if (res.success) {
|
||||||
|
createMessage.success(res.message);
|
||||||
|
emit('ok');
|
||||||
|
} else {
|
||||||
|
createMessage.warning(res.message);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
confirmLoading.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
add,
|
||||||
|
edit,
|
||||||
|
submitForm,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
.antd-modal-form {
|
||||||
|
padding: 14px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -0,0 +1,82 @@
|
||||||
|
<template>
|
||||||
|
<a-drawer :title="title" :width="width" v-model:visible="visible" :closable="true"
|
||||||
|
:footer-style="{ textAlign: 'right' }" @close="handleCancel">
|
||||||
|
<NuResourcesManagementDetailForm ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></NuResourcesManagementDetailForm>
|
||||||
|
<template #footer>
|
||||||
|
<a-button type="primary" style="margin-right: 8px" @click="handleCancel">关闭</a-button>
|
||||||
|
<a-button type="primary" @click="handleOk" v-if="!disableSubmit">确认</a-button>
|
||||||
|
</template>
|
||||||
|
</a-drawer>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref, nextTick, defineExpose } from 'vue';
|
||||||
|
import NuResourcesManagementDetailForm from './NuResourcesManagementDetailForm.vue'
|
||||||
|
import JModal from '/@/components/Modal/src/JModal/JModal.vue';
|
||||||
|
|
||||||
|
const title = ref<string>('');
|
||||||
|
const width = ref<number>(800);
|
||||||
|
const visible = ref<boolean>(false);
|
||||||
|
const disableSubmit = ref<boolean>(false);
|
||||||
|
const registerForm = ref();
|
||||||
|
const emit = defineEmits(['register', 'success']);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
*/
|
||||||
|
function add() {
|
||||||
|
title.value = '新增';
|
||||||
|
visible.value = true;
|
||||||
|
nextTick(() => {
|
||||||
|
registerForm.value.add();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
* @param record
|
||||||
|
*/
|
||||||
|
function edit(record) {
|
||||||
|
title.value = disableSubmit.value ? '详情' : '编辑';
|
||||||
|
visible.value = true;
|
||||||
|
nextTick(() => {
|
||||||
|
registerForm.value.edit(record);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 确定按钮点击事件
|
||||||
|
*/
|
||||||
|
function handleOk() {
|
||||||
|
registerForm.value.submitForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* form保存回调事件
|
||||||
|
*/
|
||||||
|
function submitCallback() {
|
||||||
|
handleCancel();
|
||||||
|
emit('success');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消按钮回调事件
|
||||||
|
*/
|
||||||
|
function handleCancel() {
|
||||||
|
visible.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
add,
|
||||||
|
edit,
|
||||||
|
disableSubmit,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less">
|
||||||
|
/**隐藏样式-modal确定按钮 */
|
||||||
|
.jee-hidden {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<style lang="less" scoped></style>
|
||||||
Loading…
Reference in New Issue