|
@@ -29,13 +29,13 @@
|
|
|
<el-button type="primary" @click="handleSaveTemporarily(1)">暂存</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="1.5">
|
|
|
- <el-button type="primary" @click="handleSave(formRef,2)"> 发布 </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-form :model="form" :rules="rules" ref="formRef">
|
|
|
+ <el-form ref="formRef" :model="form" :rules="rules">
|
|
|
<el-row :gutter="20">
|
|
|
<el-col :lg="30" :xs="24" style="margin-top: -10px">
|
|
|
<el-row :span="24" :gutter="10">
|
|
@@ -54,7 +54,15 @@
|
|
|
<!-- 截止时间 -->
|
|
|
<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-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>
|
|
|
<!-- 操作按钮 -->
|
|
@@ -65,15 +73,15 @@
|
|
|
</el-col>
|
|
|
<!-- 选择填报人 -->
|
|
|
<el-col :span="16">
|
|
|
- <el-form-item label="选择填报人:" prop="user_ids" label-width="auto" style="font-weight: bold;">
|
|
|
+ <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"
|
|
|
+ @close="handleClose(tag)"
|
|
|
>
|
|
|
{{ tag.label }}
|
|
|
</el-tag>
|
|
@@ -95,25 +103,23 @@
|
|
|
</div>
|
|
|
<informantSelect
|
|
|
v-model="isShowSelect"
|
|
|
+ v-isShowSelect
|
|
|
:tree-data="treeData"
|
|
|
- :default-check-data="selectContactSelectData"
|
|
|
- @confirm="handleContactSelectData" />
|
|
|
+ :default-check-data="form.user_ids"
|
|
|
+ @confirm="handleContactSelectData"
|
|
|
+ />
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { onMounted, ref } from 'vue';
|
|
|
-import { ElButton, ElCol, ElDatePicker, ElFormItem, ElInput, ElOption, ElRow, ElSelect, ElTable, ElTableColumn } from 'element-plus';
|
|
|
import * as XLSX from 'xlsx';
|
|
|
import { fillingAdd, fillingList } from '@/api/dataFilling/fillingManage';
|
|
|
import { HotTable } from '@handsontable/vue3';
|
|
|
-import Handsontable from 'handsontable';
|
|
|
import 'handsontable/languages';
|
|
|
import 'handsontable/dist/handsontable.full.css';
|
|
|
import { registerAllModules } from 'handsontable/registry';
|
|
|
-import informantSelect from './informantSelect.vue'
|
|
|
+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();
|
|
|
|
|
@@ -122,7 +128,7 @@ const props = defineProps<{
|
|
|
}>();
|
|
|
const fileList = ref([]);
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
-const emits = defineEmits(['close','confirm']);
|
|
|
+const emits = defineEmits(['close', 'confirm']);
|
|
|
const formRef = ref('');
|
|
|
const detailData = ref({
|
|
|
title: '表单数据',
|
|
@@ -136,9 +142,9 @@ const isShowSelect = ref(false);
|
|
|
let treeData = ref([]);
|
|
|
|
|
|
// 初始化表格数据
|
|
|
-onMounted(() => {
|
|
|
- fetchTreeData();
|
|
|
- fetchData();
|
|
|
+onMounted(async () => {
|
|
|
+ await fetchData();
|
|
|
+ await fetchTreeData();
|
|
|
});
|
|
|
|
|
|
const showTable = ref(false);
|
|
@@ -148,16 +154,16 @@ const handleNewTemplate = () => {
|
|
|
};
|
|
|
|
|
|
const form = ref({
|
|
|
- table_name: "",
|
|
|
- end_time: "",
|
|
|
- status: "0",
|
|
|
- issued_status: "",
|
|
|
- period_type: "",
|
|
|
- creator_name: "",
|
|
|
- creator_phone: "",
|
|
|
+ table_name: '',
|
|
|
+ end_time: '',
|
|
|
+ status: '0',
|
|
|
+ issued_status: '',
|
|
|
+ period_type: '',
|
|
|
+ creator_name: '',
|
|
|
+ creator_phone: '',
|
|
|
field_names: [],
|
|
|
user_ids: []
|
|
|
-})
|
|
|
+});
|
|
|
const rules = {
|
|
|
table_name: [{ required: true, message: '表名不能为空', trigger: 'blur' }],
|
|
|
end_time: [{ required: true, message: '截止时间不能为空', trigger: 'blur' }],
|
|
@@ -166,8 +172,8 @@ const rules = {
|
|
|
{ required: true, message: '联系电话不能为空', trigger: 'blur' },
|
|
|
{ validator: validatePhone, message: '请输入正确格式的联系电话', trigger: 'blur' }
|
|
|
],
|
|
|
- user_ids: [{ required: true, 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 = [];
|
|
@@ -175,7 +181,7 @@ const handleSaveTemporarily = async (statuCode) => {
|
|
|
if (!!item) {
|
|
|
data2.push(item);
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
form.value.field_names = data2;
|
|
|
}
|
|
|
form.value.issued_status = statuCode;
|
|
@@ -185,7 +191,7 @@ const handleSaveTemporarily = async (statuCode) => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
-const handleSave = async (formEl,statuCode) => {
|
|
|
+const handleSave = async (formEl, statuCode) => {
|
|
|
if (!formEl) return;
|
|
|
await formEl.validate((valid, fields) => {
|
|
|
if (valid) {
|
|
@@ -194,7 +200,7 @@ const handleSave = async (formEl,statuCode) => {
|
|
|
if (!!item) {
|
|
|
data2.push(item);
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
form.value.field_names = data2;
|
|
|
form.value.issued_status = statuCode;
|
|
|
fillingAdd(form.value).then((res) => {
|
|
@@ -216,7 +222,6 @@ const handleSave = async (formEl,statuCode) => {
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
};
|
|
|
|
|
|
const handleReturn = () => {
|
|
@@ -335,44 +340,58 @@ const handleFileUpload = ({ file }) => {
|
|
|
|
|
|
const showSelect = () => {
|
|
|
isShowSelect.value = true;
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
-const fetchTreeData = async () => {
|
|
|
- try {
|
|
|
- const response = await getPhoneList({});
|
|
|
- if (response && response.data) {
|
|
|
- treeData.value = response.data;
|
|
|
+const fetchTreeData = () => {
|
|
|
+ return getPhoneList().then((response) => {
|
|
|
+ treeData.value = response.data;
|
|
|
+ if (form.value && form.value.user_ids) {
|
|
|
+ let arr = [];
|
|
|
+ form.value.user_ids.forEach((item) => {
|
|
|
+ let res = findNodeById(treeData.value, item);
|
|
|
+ if (!!res) {
|
|
|
+ arr.push(res);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ selectedReporter.value = arr;
|
|
|
}
|
|
|
- } catch (error) {
|
|
|
- console.error('Failed to fetch information:', error);
|
|
|
- }
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
-const selectContactSelectData = ref([]);
|
|
|
const handleContactSelectData = (data) => {
|
|
|
- console.log('handleContactSelectData:', data);
|
|
|
- selectContactSelectData.value = data;
|
|
|
- // data.user_ids = data;
|
|
|
- selectedReporter.value = data;
|
|
|
+ selectedReporter.value = deepClone(data);
|
|
|
const data1 = [];
|
|
|
- selectContactSelectData.value.forEach((item) => {
|
|
|
+ data.forEach((item) => {
|
|
|
data1.push(item.id);
|
|
|
- })
|
|
|
+ });
|
|
|
form.value.user_ids = data1;
|
|
|
};
|
|
|
|
|
|
const handleClose = (tag: string) => {
|
|
|
- selectedReporter.value.splice(selectedReporter.value.indexOf(tag), 1)
|
|
|
-}
|
|
|
+ selectedReporter.value.splice(selectedReporter.value.indexOf(tag), 1);
|
|
|
+ form.value.user_ids.splice(form.value.user_ids.indexOf(tag.id), 1);
|
|
|
+};
|
|
|
|
|
|
const fetchData = () => {
|
|
|
- fillingList(props.id).then((res) => {
|
|
|
+ return fillingList(props.id).then((res) => {
|
|
|
form.value.creator_name = res.report_info.creator_name;
|
|
|
form.value.creator_phone = res.report_info.creator_phone;
|
|
|
form.value.end_time = res.report_info.end_time;
|
|
|
form.value.table_name = res.report_info.table_name;
|
|
|
form.value.user_ids = res.report_info.user_ids;
|
|
|
- })
|
|
|
+ });
|
|
|
+};
|
|
|
+function findNodeById(data, targetId) {
|
|
|
+ for (const node of data) {
|
|
|
+ if (node.id === targetId) {
|
|
|
+ return { id: node.id, label: node.label }; // 找到匹配节点,直接返回
|
|
|
+ }
|
|
|
+ if (node.children && node.children.length > 0) {
|
|
|
+ const found = findNodeById(node.children, targetId); // 递归搜索子节点
|
|
|
+ if (found) return { id: found.id, label: found.label }; // 子节点中找到则返回
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null; // 未找到返回 null
|
|
|
}
|
|
|
</script>
|
|
|
|