2024-01-09 18:14:09 +08:00
|
|
|
<template>
|
|
|
|
<div class="edit-popup">
|
|
|
|
|
2024-03-04 18:01:24 +08:00
|
|
|
<popup ref="popupRef" :title="popupTitle" :async="true" width="80%" @confirm="handleSubmit"
|
|
|
|
@close="handleClose">
|
2024-01-09 18:14:09 +08:00
|
|
|
<el-form ref="formRef" :model="formData" label-width="auto" :rules="formRules">
|
2024-03-04 18:01:24 +08:00
|
|
|
<div
|
|
|
|
style="display: flex; flex-direction: row-reverse; justify-content: flex-start;margin-bottom: 30px;">
|
2024-01-09 18:14:09 +08:00
|
|
|
|
|
|
|
<el-select class="w-[180px]" v-model="formData.dept_id" clearable placeholder="请选择部门">
|
|
|
|
<el-option v-for="(item, index) in list2" :key="index" :label="item.name" :value="item.id" />
|
|
|
|
</el-select>
|
2024-03-04 18:01:24 +08:00
|
|
|
<el-select class="w-[180px]" v-model="formData.org_id" clearable placeholder="请选择组织"
|
|
|
|
@change="deptrmt">
|
2024-01-09 18:14:09 +08:00
|
|
|
<el-option v-for="(item, index) in list1" :key="index" :label="item.name" :value="item.id" />
|
|
|
|
</el-select>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<el-row :gutter="10">
|
|
|
|
|
|
|
|
|
|
|
|
<el-col :span="8">
|
|
|
|
<el-form-item label="项目名称" prop="project_id" @click="showDialog1 = true">
|
|
|
|
<el-input v-model="project_name" clearable readonly placeholder="系统自动填写" />
|
|
|
|
</el-form-item>
|
|
|
|
</el-col> <el-col :span="8">
|
|
|
|
<el-form-item label="项目编码" prop="contract_id">
|
|
|
|
<el-input v-model="project_code" clearable disabled placeholder="系统自动填写" />
|
|
|
|
</el-form-item>
|
|
|
|
</el-col>
|
2024-01-25 16:31:34 +08:00
|
|
|
<el-col :span="8">
|
|
|
|
<el-form-item label="希望到货日期" prop="arrival_date"
|
|
|
|
:rules="[{ required: true, message: '不可为空', trigger: 'change' }]">
|
|
|
|
|
|
|
|
<el-date-picker class="flex-1 !flex" v-model="formData.arrival_date" clearable type="date"
|
|
|
|
value-format="YYYY-MM-DD " placeholder="选择希望到货日期">
|
|
|
|
</el-date-picker>
|
2024-01-09 18:14:09 +08:00
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
</el-col>
|
|
|
|
<el-col :span="8">
|
2024-01-14 19:36:58 +08:00
|
|
|
<el-form-item label="申请日期" prop="apply_date"
|
|
|
|
:rules="[{ required: true, message: '不可为空', trigger: 'change' }]">
|
2024-01-09 18:14:09 +08:00
|
|
|
|
2024-01-14 19:36:58 +08:00
|
|
|
<el-date-picker class="flex-1 !flex" v-model="formData.apply_date" clearable type="date"
|
|
|
|
value-format="YYYY-MM-DD" placeholder="选择申请日期">
|
2024-01-09 18:14:09 +08:00
|
|
|
</el-date-picker>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
</el-col>
|
2024-01-25 16:31:34 +08:00
|
|
|
<el-col :span="12">
|
|
|
|
<el-form-item label="备注" prop="remark">
|
|
|
|
<el-input v-model="formData.remark" type="textarea" clearable placeholder="请输入备注" />
|
2024-01-09 18:14:09 +08:00
|
|
|
</el-form-item>
|
|
|
|
</el-col>
|
2024-01-25 16:31:34 +08:00
|
|
|
|
|
|
|
|
2024-01-09 18:14:09 +08:00
|
|
|
<el-col :span="24">
|
2024-03-13 14:47:51 +08:00
|
|
|
|
|
|
|
<el-form-item label="附件">
|
2024-01-14 19:36:58 +08:00
|
|
|
<el-upload
|
|
|
|
accept="doc, docx, xls, xlsx, ppt, pptx, pdf, txt, zip, rar, tar, jpg, png, gif, jpeg, webp, wmv, avi, mpg, mpeg, 3gp, mov, mp4, flv, f4v, rmvb, mkv"
|
|
|
|
class="upload-demo" :show-file-list="false" aria-hidden="true"
|
|
|
|
:headers="{ Token: userStore.token }" :action="base_url + '/upload/file'"
|
|
|
|
:on-success="handleAvatarSuccess_four" ref="upload">
|
2024-01-09 18:14:09 +08:00
|
|
|
<el-button type="primary">
|
|
|
|
上传
|
|
|
|
</el-button>
|
|
|
|
</el-upload>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<div v-for="(item, index) in formDataannex" style="margin-left: 5px;display: block;">
|
2024-03-04 18:01:24 +08:00
|
|
|
<a style="margin-left: 10px; color: #4a5dff; align-self: flex-start"
|
|
|
|
:href="item.uri" target="_blank">{{ item.name }}</a>
|
2024-01-09 18:14:09 +08:00
|
|
|
<span style="cursor: pointer;margin-left: 5px;" @click="delFileFn(index)">x</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
</el-col>
|
|
|
|
</el-row>
|
|
|
|
|
2024-03-04 18:01:24 +08:00
|
|
|
<div style="margin: 20px 0;" v-if="mode == 'add'">申购明细</div>
|
|
|
|
<el-col :span="24" v-if="mode == 'add'">
|
2024-01-09 18:14:09 +08:00
|
|
|
<div style=" display: flex;justify-content: flex-end;margin-bottom: 30px;">
|
|
|
|
<el-button @click="showDialog = true" type="primary" plain>选择材料</el-button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</el-col>
|
2024-03-04 18:01:24 +08:00
|
|
|
<el-row v-if="mode == 'add'">
|
2024-01-09 18:14:09 +08:00
|
|
|
<el-table :data="tablist1">
|
|
|
|
<el-table-column label="序号">
|
|
|
|
<template #default="{ row }">
|
|
|
|
|
|
|
|
<el-button @click="handleAdd(row)" size="small">+</el-button>
|
|
|
|
<el-button @click="handleDelete(row)" size="small">-</el-button>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column label="材料名称" prop="material_name">
|
2024-03-04 18:01:24 +08:00
|
|
|
|
2024-01-09 18:14:09 +08:00
|
|
|
<template #default="{ row, $index }">
|
|
|
|
<el-input v-model="row.material_name" disabled @click="subjectmu(row, $index)" />
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column label="材料编码" prop="material_code">
|
2024-03-04 18:01:24 +08:00
|
|
|
|
2024-01-09 18:14:09 +08:00
|
|
|
<template #default="{ row }">
|
|
|
|
<el-input v-model="row.material_code" disabled />
|
|
|
|
</template></el-table-column>
|
|
|
|
|
|
|
|
<el-table-column label="规格型号" prop="material_specs">
|
2024-03-04 18:01:24 +08:00
|
|
|
|
2024-01-09 18:14:09 +08:00
|
|
|
<template #default="{ row }">
|
|
|
|
<el-input v-model="row.material_specs" disabled /> </template>
|
|
|
|
</el-table-column>
|
|
|
|
|
|
|
|
<el-table-column label="品牌" prop="material_brand">
|
2024-03-04 18:01:24 +08:00
|
|
|
|
2024-01-09 18:14:09 +08:00
|
|
|
<template #default="{ row }">
|
|
|
|
<el-input v-model="row.material_brand" disabled /> </template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column label="参数说明" prop="material_parameter_description">
|
2024-03-04 18:01:24 +08:00
|
|
|
|
2024-01-09 18:14:09 +08:00
|
|
|
<template #default="{ row }">
|
|
|
|
<el-input v-model="row.material_parameter_description" disabled /> </template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column label="单位" prop="material_unit">
|
2024-03-04 18:01:24 +08:00
|
|
|
|
2024-01-09 18:14:09 +08:00
|
|
|
<template #default="{ row }">
|
|
|
|
<el-input v-model="row.material_unit" disabled /> </template>
|
|
|
|
</el-table-column>
|
2024-01-25 16:31:34 +08:00
|
|
|
<el-table-column label="可申购数量" prop="residual_num">
|
2024-03-04 18:01:24 +08:00
|
|
|
|
2024-01-25 16:31:34 +08:00
|
|
|
<template #default="{ row }">
|
|
|
|
<el-input v-model="row.residual_num" disabled /> </template>
|
|
|
|
</el-table-column>
|
2024-01-09 18:14:09 +08:00
|
|
|
|
|
|
|
<el-table-column label="申请采购数量" prop="num">
|
2024-03-04 18:01:24 +08:00
|
|
|
|
2024-01-09 18:14:09 +08:00
|
|
|
<template #default="{ row }">
|
|
|
|
<el-input v-model="row.num" /> </template>
|
|
|
|
</el-table-column>
|
|
|
|
|
|
|
|
<el-table-column label="备注" prop="remark">
|
2024-03-04 18:01:24 +08:00
|
|
|
|
2024-01-09 18:14:09 +08:00
|
|
|
<template #default="{ row }">
|
|
|
|
<el-input v-model="row.remark" /> </template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table>
|
|
|
|
|
|
|
|
|
|
|
|
</el-row>
|
2024-01-22 11:00:38 +08:00
|
|
|
<div v-if="showDialog">
|
|
|
|
<el-dialog v-model="showDialog" title="选择材料预算" width="70%">
|
|
|
|
<materialDialog @customEvent="customEvent" :project_id="formData.project_id"></materialDialog>
|
|
|
|
</el-dialog>
|
|
|
|
</div>
|
2024-01-09 18:14:09 +08:00
|
|
|
|
|
|
|
<el-dialog v-model="showDialog1" title="选择项目" width="70%">
|
|
|
|
<projectDialog @customEvent="customEvent1"></projectDialog>
|
|
|
|
</el-dialog>
|
|
|
|
</el-form>
|
|
|
|
</popup>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup name="projectEdit">
|
|
|
|
import materialDialog from '@/components/material_budget_detail/index.vue'
|
|
|
|
import type { FormInstance } from 'element-plus'
|
|
|
|
import Popup from '@/components/popup/index.vue'
|
|
|
|
import { toChinesNum } from "@/utils/util";
|
|
|
|
import projectDialog from '@/components/project/index.vue'
|
|
|
|
import { materialrequestAdd, materialrequestEdit, materialrequestDetail } from '@/api/material_purchase_request'
|
2024-03-04 18:01:24 +08:00
|
|
|
import { materialrequestDetailLists } from '@/api/material_purchase_request_detail'
|
|
|
|
|
2024-01-09 18:14:09 +08:00
|
|
|
import { getAllProjectTypes } from '@/api/projecttype'
|
|
|
|
import { timeFormat } from '@/utils/util'
|
|
|
|
import { isEmail, isIdCard, isPhone } from '@/utils/validate'
|
|
|
|
import type { PropType } from 'vue'
|
|
|
|
import configs from "@/config"
|
|
|
|
import useUserStore from "@/stores/modules/user";
|
|
|
|
const list1 = reactive([])
|
|
|
|
const list2 = reactive([])
|
|
|
|
import { deptAll } from '@/api/org/department'
|
|
|
|
import { getAll } from '@/api/org/organization'
|
|
|
|
|
|
|
|
|
|
|
|
const base_url = configs.baseUrl + configs.urlPrefix
|
|
|
|
const userStore = useUserStore();
|
|
|
|
const active = ref(0)
|
|
|
|
const formDataannex = reactive([])
|
|
|
|
const project_name = ref('')
|
|
|
|
const project_code = ref('')
|
|
|
|
|
|
|
|
const tablist1 = reactive([])
|
|
|
|
const next = () => {
|
|
|
|
if (active.value++ > 3) active.value = 0
|
|
|
|
}
|
|
|
|
// 上传文件
|
|
|
|
const handleAvatarSuccess_four = (
|
|
|
|
response,
|
|
|
|
uploadFile
|
|
|
|
) => {
|
|
|
|
if (response.code == 0) {
|
|
|
|
ElMessage.error(response.msg);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
formDataannex.push(
|
|
|
|
{ uri: response.data.uri, name: response.data.name }
|
|
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleAdd = (row: any) => {
|
|
|
|
// 在 row 后面插入一行数据
|
|
|
|
const index = tablist1.indexOf(row);
|
|
|
|
tablist1.splice(index + 1, 0, {});
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleDelete = (row: any) => {
|
|
|
|
// 删除 row
|
|
|
|
const index = tablist1.indexOf(row);
|
|
|
|
tablist1.splice(index, 1);
|
|
|
|
};
|
|
|
|
|
|
|
|
// 删除上传的文件
|
|
|
|
const delFileFn = (index: number) => {
|
|
|
|
formDataannex.splice(index, 1)
|
|
|
|
}
|
|
|
|
//获取所有组织
|
|
|
|
const getlist = () => {
|
|
|
|
getAll().then((res) => {
|
|
|
|
Object.assign(list1, res)
|
|
|
|
if (res.length > 0 && !formData.org_id) {
|
|
|
|
formData.org_id = res[0].id
|
|
|
|
deptAll({ 'org_id': res[0].id }).then((res) => {
|
|
|
|
if (res.length > 0) {
|
|
|
|
Object.assign(list2, res)
|
|
|
|
formData.dept_id = res[0].id
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
//获取部门
|
|
|
|
const deptrmt = (e: any) => {
|
|
|
|
formData.dept_id = ''
|
|
|
|
getlist1(e)
|
|
|
|
|
|
|
|
}
|
|
|
|
//获取所有部门
|
|
|
|
const getlist1 = (id: any) => {
|
|
|
|
deptAll({ 'org_id': id }).then((res) => {
|
|
|
|
list2.splice(0, list2.length, ...res)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
defineProps({
|
|
|
|
dictData: {
|
|
|
|
type: Object as PropType<Record<string, any[]>>,
|
|
|
|
default: () => ({})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
const emit = defineEmits(['success', 'close'])
|
|
|
|
const formRef = shallowRef<FormInstance>()
|
|
|
|
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
|
|
|
const mode = ref('add')
|
|
|
|
const showDialog = ref(false)
|
|
|
|
const showDialog1 = ref(false)
|
|
|
|
|
|
|
|
const customEvent = (e: any) => {
|
2024-01-24 18:52:44 +08:00
|
|
|
tablist1.push({
|
2024-01-09 18:14:09 +08:00
|
|
|
'id': e.id,
|
|
|
|
'material_name': e.material_name,
|
|
|
|
'material_code': e.material_code,
|
|
|
|
'material_specs': e.material_specs,
|
|
|
|
'material_parameter_description': e.material_parameter_description,
|
|
|
|
'material_brand': e.material_brand,
|
2024-01-25 16:31:34 +08:00
|
|
|
'material_unit': e.material_unit,
|
|
|
|
residual_num: e.residual_num
|
2024-01-09 18:14:09 +08:00
|
|
|
})
|
|
|
|
showDialog.value = false;
|
|
|
|
};
|
|
|
|
const customEvent1 = (e: any) => {
|
|
|
|
formData.project_id = e.id;
|
|
|
|
project_name.value = e.name;
|
|
|
|
project_code.value = e.project_code;
|
|
|
|
showDialog1.value = false;
|
2024-01-25 16:31:34 +08:00
|
|
|
tablist1.splice(0, 99999)
|
2024-01-09 18:14:09 +08:00
|
|
|
};
|
|
|
|
// 弹窗标题
|
|
|
|
const popupTitle = computed(() => {
|
|
|
|
return mode.value == 'edit' ? '编辑采购需求目表' : '新增采购需求表'
|
|
|
|
})
|
|
|
|
|
|
|
|
// 表单数据
|
|
|
|
const formData = reactive({
|
|
|
|
id: '',
|
|
|
|
org_id: '',
|
|
|
|
dept_id: '',
|
|
|
|
project_id: '',
|
2024-03-04 18:01:24 +08:00
|
|
|
project_name: '',
|
|
|
|
project_code: '',
|
2024-01-09 18:14:09 +08:00
|
|
|
apply_date: '',
|
|
|
|
arrival_date: '',
|
|
|
|
remark: '',
|
2024-01-14 19:36:58 +08:00
|
|
|
annex: [],
|
|
|
|
purchase_request_detail: [],
|
2024-01-09 18:14:09 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
// 表单验证
|
|
|
|
const formRules = reactive<any>({
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 获取详情
|
|
|
|
const setFormData = async (data: Record<any, any>) => {
|
|
|
|
if (data.annex && data.annex.length > 0) {
|
|
|
|
|
|
|
|
const arry1 = data.annex.map((item: any, index: any) => {
|
|
|
|
return {
|
|
|
|
name: `文件${index + 1}`,
|
|
|
|
uri: item
|
|
|
|
};
|
|
|
|
});
|
|
|
|
Object.assign(formDataannex, arry1)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data.dept_id) {
|
|
|
|
getlist1(data.org_id)
|
|
|
|
}
|
|
|
|
for (const key in formData) {
|
|
|
|
if (data[key] != null && data[key] != undefined) {
|
|
|
|
//@ts-ignore
|
|
|
|
formData[key] = data[key]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-03-04 18:01:24 +08:00
|
|
|
project_name.value = data.project_name;
|
|
|
|
project_code.value = data.project_code
|
|
|
|
materialrequestDetailLists({ project_material_budget_detail_id: formData.id }).then(res => {
|
|
|
|
res.lists.forEach((item, index) => {
|
|
|
|
tablist1[index] = res.lists[index]
|
|
|
|
})
|
|
|
|
})
|
2024-01-09 18:14:09 +08:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
const getDetail = async (row: Record<string, any>) => {
|
|
|
|
const data = await materialrequestDetail({
|
|
|
|
id: row.id
|
|
|
|
})
|
|
|
|
setFormData(data)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 提交按钮
|
|
|
|
const handleSubmit = async () => {
|
|
|
|
if (formDataannex.length > 0) {
|
2024-01-14 19:36:58 +08:00
|
|
|
formData.annex = formDataannex.map((item: any) => item.uri)
|
2024-01-09 18:14:09 +08:00
|
|
|
}
|
|
|
|
if (tablist1.length > 0) {
|
2024-01-14 19:36:58 +08:00
|
|
|
formData.purchase_request_detail = tablist1.map((item) => ({
|
2024-01-09 18:14:09 +08:00
|
|
|
"project_material_budget_detail_id": item.id,
|
|
|
|
"num": item.num,
|
|
|
|
"remark": item.remark
|
2024-01-14 19:36:58 +08:00
|
|
|
}))
|
2024-01-09 18:14:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
await formRef.value?.validate()
|
|
|
|
|
|
|
|
|
|
|
|
const data = { ...formData }
|
|
|
|
mode.value == 'edit'
|
|
|
|
? await materialrequestEdit(data)
|
|
|
|
: await materialrequestAdd(data)
|
|
|
|
popupRef.value?.close()
|
|
|
|
emit('success')
|
|
|
|
}
|
|
|
|
|
|
|
|
//打开弹窗
|
|
|
|
const open = (type = 'add') => {
|
|
|
|
mode.value = type
|
|
|
|
popupRef.value?.open()
|
|
|
|
|
|
|
|
getlist()
|
|
|
|
}
|
|
|
|
|
|
|
|
// 关闭回调
|
|
|
|
const handleClose = () => {
|
|
|
|
emit('close')
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
open,
|
|
|
|
setFormData,
|
|
|
|
getDetail
|
|
|
|
})
|
|
|
|
</script>
|