|
@@ -15,67 +15,69 @@
|
|
|
<el-button type="primary" @click="handleNewTemplate">重新加载</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="1.5">
|
|
|
- <el-button type="primary" @click="handleSaveTemporarily">暂存</el-button>
|
|
|
+ <el-button type="primary" @click="handleSaveTemporarily(1)">暂存</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="1.5">
|
|
|
- <el-button type="primary" @click="handleSave()"> 发布 </el-button>
|
|
|
+ <el-button type="primary" @click="handleSave(formRef,2)"> 发布 </el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="1.5">
|
|
|
<el-button type="danger" @click="handleReturn()"> 返回 </el-button>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
- <el-row :gutter="20">
|
|
|
- <el-col :lg="30" :xs="24" style="margin-top: -10px">
|
|
|
- <el-row :span="24" :gutter="10">
|
|
|
- <!-- 联系人姓名 -->
|
|
|
- <el-col :span="8">
|
|
|
- <el-form-item label="联系人姓名:" prop="table_name" label-width="auto">
|
|
|
- <el-input v-model="creator_name" placeholder="请输入联系人姓名" style="width: 300px"></el-input>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <!-- 联系电话 -->
|
|
|
- <el-col :span="8">
|
|
|
- <el-form-item label="联 系 电 话:" prop="table_phone" label-width="auto">
|
|
|
- <el-input v-model="creator_phone" placeholder="请输入联系电话" style="width: 300px"></el-input>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
+ <el-form :model="form" :rules="rules" ref="formRef">
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :lg="30" :xs="24" style="margin-top: -10px">
|
|
|
+ <el-row :span="24" :gutter="10">
|
|
|
+ <!-- 联系人姓名 -->
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="联系人姓名:" prop="creator_name" label-width="auto">
|
|
|
+ <el-input v-model="form.creator_name" placeholder="请输入联系人姓名" style="width: 300px"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <!-- 联系电话 -->
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="联 系 电 话:" prop="creator_phone" label-width="auto">
|
|
|
+ <el-input v-model="form.creator_phone" placeholder="请输入联系电话" style="width: 300px"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <!-- 截止时间 -->
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="截 止 时 间 :" prop="end_time">
|
|
|
+ <el-date-picker v-model="form.end_time" value-format="YYYY-MM-DD HH:mm:ss" time-format="HH:mm" type="datetime" placeholder="选择截止时间" style="width: 300px" @change="handleTimeChange" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <!-- 操作按钮 -->
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="表           名:" prop="table_name" label-width="auto">
|
|
|
+ <el-input v-model="form.table_name" placeholder="请输入表名" style="width: 300px"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <!-- 选择填报人 -->
|
|
|
+ <el-col :span="16">
|
|
|
+ <el-form-item label="选择填报人:" prop="user_ids" label-width="auto" style="font-weight: bold;">
|
|
|
+ <div>
|
|
|
+ <el-tag
|
|
|
+ v-for="tag in selectedReporter"
|
|
|
+ :key="tag"
|
|
|
+ closable
|
|
|
+ :disable-transitions="false"
|
|
|
+ @close="handleClose(tag)"
|
|
|
+ style="margin-right: 10px"
|
|
|
+ >
|
|
|
+ {{ tag.label }}
|
|
|
+ </el-tag>
|
|
|
+ </div>
|
|
|
+ <el-button @click="showSelect">点击选择</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <!-- <el-col :span="8">-->
|
|
|
+ <!-- <el-button type="primary" @click="handleReport()"> 智能识别 </el-button>-->
|
|
|
+ <!-- </el-col>-->
|
|
|
+ </el-row>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
|
|
|
- <!-- 截止时间 -->
|
|
|
- <el-col :span="8">
|
|
|
- <el-form-item label="截 止 时 间 :" prop="release_time">
|
|
|
- <el-date-picker v-model="selectedTime" type="date" placeholder="选择截止时间" style="width: 150px" @change="handleTimeChange" />
|
|
|
- <span class="label" style="margin-left: 20px">前报送该表</span>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <!-- 操作按钮 -->
|
|
|
- <el-col :span="8">
|
|
|
- <el-form-item label="表           名:" prop="table_name" label-width="auto">
|
|
|
- <el-input v-model="table_name" placeholder="请输入表名" style="width: 300px"></el-input>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <!-- 选择填报人 -->
|
|
|
- <el-col :span="16">
|
|
|
- <el-form-item label="选择填报人:" prop="selectedName" label-width="auto" style="font-weight: bold;">
|
|
|
- <div class="flex gap-2">
|
|
|
- <el-tag
|
|
|
- v-for="tag in selectedReporter"
|
|
|
- :key="tag"
|
|
|
- closable
|
|
|
- :disable-transitions="false"
|
|
|
- @close="handleClose(tag)"
|
|
|
- >
|
|
|
- {{ tag.label }}
|
|
|
- </el-tag>
|
|
|
- </div>
|
|
|
- <el-button @click="showSelect" style="margin-left: 10px">点击选择</el-button>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <!-- <el-col :span="8">-->
|
|
|
- <!-- <el-button type="primary" @click="handleReport()"> 智能识别 </el-button>-->
|
|
|
- <!-- </el-col>-->
|
|
|
- </el-row>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
<div style="height: 350px">
|
|
|
<hot-table v-if="showTable" ref="wrapper" :data="hotData" :settings="hotSettings" />
|
|
|
</div>
|
|
@@ -99,11 +101,15 @@ import 'handsontable/dist/handsontable.full.css';
|
|
|
import { registerAllModules } from 'handsontable/registry';
|
|
|
import informantSelect from './informantSelect.vue'
|
|
|
import { getPhoneList } from '@/api/informationissue/informationissue';
|
|
|
+import { deepClone } from '@/utils';
|
|
|
+import { createWarehousingEntry } from '@/api/comprehensiveGuarantee/materialReserveManagement/InboundManagement';
|
|
|
+import { validatePhone } from '@/utils/validate';
|
|
|
registerAllModules();
|
|
|
|
|
|
const fileList = ref([]);
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
const emits = defineEmits(['close']);
|
|
|
+const formRef = ref('');
|
|
|
const detailData = ref({
|
|
|
title: '表单数据',
|
|
|
start: '2024-10-15 17:02:22',
|
|
@@ -121,7 +127,7 @@ const selectedTime = ref(null);
|
|
|
const table_name = ref('');
|
|
|
const data_table_name = ref(''); // 假设这是另一个输入字段,需要在模板中添加对应的输入框
|
|
|
const status = ref(0); // 假设这是一个选择器或输入框
|
|
|
-const issued_status = ref(0); // 假设这是一个选择器或输入框
|
|
|
+const issued_status = ref(2); // 假设这是一个选择器或输入框
|
|
|
const period_type = ref(''); // 假设这是一个输入框或选择器
|
|
|
const creator_id = ref(null); // 这通常是用户ID,可能需要从登录信息中获取
|
|
|
const isShowSelect = ref(false);
|
|
@@ -166,45 +172,79 @@ const handleReload = () => {
|
|
|
hotData.value = [];
|
|
|
alert('表格已清空');
|
|
|
};
|
|
|
+const form = ref({
|
|
|
+ table_name: "",
|
|
|
+ end_time: "",
|
|
|
+ status: "0",
|
|
|
+ issued_status: "",
|
|
|
+ period_type: "",
|
|
|
+ creator_name: "",
|
|
|
+ creator_phone: "13423232323",
|
|
|
+ field_names: [],
|
|
|
+ user_ids: []
|
|
|
+})
|
|
|
+const rules = {
|
|
|
+ table_name: [{ required: true, message: '表名不能为空', trigger: 'blur' }],
|
|
|
+ end_time: [{ required: true, message: '截止时间不能为空', trigger: 'blur' }],
|
|
|
+ creator_name: [{ required: true, message: '联系人姓名不能为空', trigger: 'blur' }],
|
|
|
+ creator_phone: [
|
|
|
+ { required: true, message: '联系电话不能为空', trigger: 'blur' },
|
|
|
+ { validator: validatePhone, message: '请输入正确格式的联系电话', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ user_ids: [{ required: true, message: '请选择填报人', trigger: 'blur' }],
|
|
|
+}
|
|
|
+const handleSaveTemporarily = async (statuCode) => {
|
|
|
+ if (hotData.value && hotData.value[0] && hotData.value[0].length > 0) {
|
|
|
+ const data2 = [];
|
|
|
+ hotData.value[0].forEach((item) => {
|
|
|
+ if (!!item) {
|
|
|
+ data2.push(item);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ form.value.field_names = data2;
|
|
|
+ }
|
|
|
|
|
|
-const handleSaveTemporarily = () => {
|
|
|
- localStorage.setItem('field_names', JSON.stringify(field_names.value));
|
|
|
- alert('数据已暂存');
|
|
|
+ form.value.issued_status = statuCode;
|
|
|
+ fillingAdd(form.value).then(() => {
|
|
|
+ proxy.$modal.msgSuccess('暂存成功');
|
|
|
+ emits('close');
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
const handleReport = () => console.log('上报');
|
|
|
|
|
|
-const handleSave = async () => {
|
|
|
- // 构造要发送的数据对象
|
|
|
- const data = {
|
|
|
- table_name: table_name.value,
|
|
|
- data_table_name: data_table_name.value,
|
|
|
- start_time: selectedTime.value,
|
|
|
- end_time: selectedTime.value,
|
|
|
- status: status.value,
|
|
|
- issued_status: issued_status.value,
|
|
|
- period_type: period_type.value,
|
|
|
- creator_name: creator_name.value,
|
|
|
- creator_id: creator_id.value,
|
|
|
- creator_phone: creator_phone.value,
|
|
|
- field_names: field_names.value,
|
|
|
- user_ids: [] // 这个需要根据实际情况来填充
|
|
|
- };
|
|
|
-
|
|
|
- // 保存本地状态
|
|
|
- localStorage.setItem('field_names', JSON.stringify(field_names.value));
|
|
|
- try {
|
|
|
- // 调用fillingAdd接口,传递data作为请求体
|
|
|
- const response = await fillingAdd(data);
|
|
|
- if (response && response.success) {
|
|
|
- alert('数据已成功保存');
|
|
|
+const handleSave = async (formEl,statuCode) => {
|
|
|
+ if (!formEl) return;
|
|
|
+ await formEl.validate((valid, fields) => {
|
|
|
+ if (valid) {
|
|
|
+ const data2 = [];
|
|
|
+ hotData.value[0].forEach((item) => {
|
|
|
+ if (!!item) {
|
|
|
+ data2.push(item);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ form.value.field_names = data2;
|
|
|
+ form.value.issued_status = statuCode;
|
|
|
+ fillingAdd(form.value).then((res) => {
|
|
|
+ proxy.$modal.msgSuccess('发布成功');
|
|
|
+ emits('close');
|
|
|
+ });
|
|
|
} else {
|
|
|
- alert('数据保存失败');
|
|
|
+ nextTick(() => {
|
|
|
+ let isError = document.getElementsByClassName('is-error');
|
|
|
+ isError[0].scrollIntoView({
|
|
|
+ // 滚动到指定节点
|
|
|
+ // 值有start,center,end,nearest,当前显示在视图区域中间
|
|
|
+ block: 'center',
|
|
|
+ // 值有auto、instant,smooth,缓动动画(当前是慢速的)
|
|
|
+ behavior: 'smooth'
|
|
|
+ });
|
|
|
+ });
|
|
|
+ proxy.$modal.msgError('表单校验失败');
|
|
|
+ return false;
|
|
|
}
|
|
|
- } catch (error) {
|
|
|
- console.error('保存数据失败:', error);
|
|
|
- alert('数据保存失败');
|
|
|
- }
|
|
|
+ });
|
|
|
+
|
|
|
};
|
|
|
|
|
|
const handleReturn = () => {
|
|
@@ -342,6 +382,11 @@ const handleContactSelectData = (data) => {
|
|
|
selectContactSelectData.value = data;
|
|
|
// data.user_ids = data;
|
|
|
selectedReporter.value = data;
|
|
|
+ const data1 = [];
|
|
|
+ selectContactSelectData.value.forEach((item) => {
|
|
|
+ data1.push(item.id);
|
|
|
+ })
|
|
|
+ form.value.user_ids = data1;
|
|
|
};
|
|
|
|
|
|
const handleClose = (tag: string) => {
|