242 lines
8.3 KiB
Vue
242 lines
8.3 KiB
Vue
![]() |
<template>
|
||
|
<div class="edit-popup">
|
||
|
|
||
|
<popup ref="popupRef" :title="popupTitle" :async="true" width="550px" @confirm="handleSubmit" @close="handleClose">
|
||
|
|
||
|
<el-form ref="formRef" :model="formData" label-width="auto" :rules="formRules">
|
||
|
|
||
|
|
||
|
|
||
|
<el-row :gutter="10">
|
||
|
|
||
|
<el-col :span="24">
|
||
|
<el-form-item label="分部工程" prop="division_id" @click="showDialog = true" :rules="[{ required: true, message: '不可为空', trigger: 'blur' }]">
|
||
|
<el-input v-model="division_engineering" readonly clearable placeholder="请输入分部工程" />
|
||
|
</el-form-item>
|
||
|
</el-col>
|
||
|
<el-col :span="24">
|
||
|
<el-form-item label="子分部工程" prop="division_id" :rules="[{ required: true, message: '不可为空', trigger: 'blur' }]">
|
||
|
<el-input v-model="sub_division_engineering" readonly clearable placeholder="请输入子分部工程" />
|
||
|
</el-form-item>
|
||
|
</el-col>
|
||
|
|
||
|
<el-col :span="24">
|
||
|
<el-form-item label="分项工程" prop="division_id" :rules="[{ required: true, message: '不可为空', trigger: 'blur' }]">
|
||
|
<el-input v-model="subentry_engineering" readonly clearable placeholder="请输入分项工程" />
|
||
|
|
||
|
</el-form-item>
|
||
|
</el-col>
|
||
|
|
||
|
<el-col :span="24">
|
||
|
<el-form-item label="分项工程编码" prop="division_id" :rules="[{ required: true, message: '不可为空', trigger: 'blur' }]">
|
||
|
<el-input v-model="subentry_engineering_code" readonly clearable placeholder="请输入分项工程编码" />
|
||
|
</el-form-item>
|
||
|
</el-col>
|
||
|
<el-col :span="24">
|
||
|
<el-form-item label="工序步骤号" prop="process_step_no" :rules="[{ required: true, message: '不可为空', trigger: 'blur' }]">
|
||
|
<el-input v-model="formData.process_step_no" clearable placeholder="请输入工序步骤号" />
|
||
|
</el-form-item>
|
||
|
</el-col>
|
||
|
<el-col :span="24">
|
||
|
<el-form-item label="工序步骤" prop="process_step" :rules="[{ required: true, message: '不可为空', trigger: 'blur' }]">
|
||
|
<el-input v-model="formData.process_step" clearable placeholder="请输入工序步骤" />
|
||
|
</el-form-item>
|
||
|
</el-col>
|
||
|
<el-col :span="24">
|
||
|
<el-form-item label="图例说明">
|
||
|
<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">
|
||
|
<el-button type="primary">
|
||
|
上传
|
||
|
</el-button>
|
||
|
</el-upload>
|
||
|
|
||
|
<div>
|
||
|
|
||
|
<div v-for="(item, index) in formDataannex" style="margin-left: 5px;display: block;">
|
||
|
<a style="margin-left: 10px; color: #4a5dff; align-self: flex-start" :href="item.uri" target="_blank">{{ item.name }}</a>
|
||
|
<span style="cursor: pointer;margin-left: 5px;" @click="delFileFn(index)">x</span>
|
||
|
</div>
|
||
|
</div>
|
||
|
</el-form-item>
|
||
|
</el-col>
|
||
|
<el-col :span="24">
|
||
|
<el-form-item label="质量控制点" prop="quality_control_points" :rules="[{ required: true, message: '不可为空', trigger: 'blur' }]">
|
||
|
<el-input v-model="formData.quality_control_points" clearable placeholder="请输入质量控制点" />
|
||
|
</el-form-item>
|
||
|
</el-col>
|
||
|
|
||
|
</el-row>
|
||
|
|
||
|
|
||
|
|
||
|
<el-dialog v-model="showDialog" title="选择客户" width="70%">
|
||
|
<customDialog @customEvent="customEvent"></customDialog>
|
||
|
</el-dialog>
|
||
|
|
||
|
|
||
|
|
||
|
</el-form>
|
||
|
</popup>
|
||
|
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script lang="ts" setup name="projectEdit">
|
||
|
import customDialog from '@/components/build_division/index.vue'
|
||
|
import type { FormInstance } from 'element-plus'
|
||
|
import Popup from '@/components/popup/index.vue'
|
||
|
|
||
|
import { buildprocesssettingsAdd, buildprocesssettingsEdit, buildprocesssettingsDetail } from '@/api/build/build_process_settings'
|
||
|
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 base_url = configs.baseUrl + configs.urlPrefix
|
||
|
const userStore = useUserStore();
|
||
|
const formDataannex = reactive([])
|
||
|
const showDialog = ref(false)
|
||
|
const subentry_engineering = ref('')
|
||
|
const subentry_engineering_code = ref('')
|
||
|
const sub_division_engineering = ref('')
|
||
|
const division_engineering = ref('')
|
||
|
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 handleAvatarSuccess_four = (
|
||
|
response,
|
||
|
uploadFile
|
||
|
) => {
|
||
|
if (response.code == 0) {
|
||
|
ElMessage.error(response.msg);
|
||
|
return;
|
||
|
}
|
||
|
formDataannex.push(
|
||
|
{ uri: response.data.uri, name: response.data.name }
|
||
|
|
||
|
|
||
|
);
|
||
|
};
|
||
|
|
||
|
// 删除上传的文件
|
||
|
const delFileFn = (index: number) => {
|
||
|
formDataannex.splice(index, 1)
|
||
|
}
|
||
|
|
||
|
// 弹窗标题
|
||
|
const popupTitle = computed(() => {
|
||
|
return mode.value == 'edit' ? '编辑分部分项划分表' : '新增分部分项划分表'
|
||
|
})
|
||
|
|
||
|
// 表单数据
|
||
|
const formData = reactive({
|
||
|
id: '',
|
||
|
process_step_no: '',
|
||
|
process_step: '',
|
||
|
quality_control_points: '',
|
||
|
division_id: '',
|
||
|
})
|
||
|
|
||
|
const customEvent = (e) => {
|
||
|
formData.division_id = e.id;
|
||
|
subentry_engineering.value = e.subentry_engineering
|
||
|
subentry_engineering_code.value = e.subentry_engineering_code
|
||
|
sub_division_engineering.value = e.sub_division_engineering
|
||
|
division_engineering.value = e.division_engineering
|
||
|
showDialog.value = false
|
||
|
}
|
||
|
|
||
|
// 表单验证
|
||
|
const formRules = reactive<any>({
|
||
|
|
||
|
})
|
||
|
|
||
|
|
||
|
|
||
|
// 获取详情
|
||
|
const setFormData = async (data: Record<any, any>) => {
|
||
|
|
||
|
if (data.file && data.file.length > 0) {
|
||
|
if (data.file.includes(",")) {
|
||
|
const arry1 = data.file.split(',').map((item: any, index: any) => {
|
||
|
return {
|
||
|
name: `文件${index + 1}`,
|
||
|
uri: item
|
||
|
};
|
||
|
});
|
||
|
Object.assign(formDataannex, arry1)
|
||
|
} else {
|
||
|
const arry1 = [{ name: `文件1`, uri: data.file }]
|
||
|
Object.assign(formDataannex, arry1)
|
||
|
console.log(formDataannex)
|
||
|
|
||
|
}
|
||
|
}
|
||
|
for (const key in formData) {
|
||
|
if (data[key] != null && data[key] != undefined) {
|
||
|
//@ts-ignore
|
||
|
formData[key] = data[key]
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
const getDetail = async (row: Record<string, any>) => {
|
||
|
const data = await buildprocesssettingsDetail({
|
||
|
id: row.id
|
||
|
})
|
||
|
setFormData(data)
|
||
|
}
|
||
|
|
||
|
|
||
|
// 提交按钮
|
||
|
const handleSubmit = async () => {
|
||
|
|
||
|
if (formDataannex.length > 0) {
|
||
|
formData.file = JSON.stringify(formDataannex.map((item: any) => item.uri))
|
||
|
}
|
||
|
|
||
|
await formRef.value?.validate()
|
||
|
|
||
|
const data = { ...formData }
|
||
|
mode.value == 'edit'
|
||
|
? await buildprocesssettingsEdit(data)
|
||
|
: await buildprocesssettingsAdd(data)
|
||
|
popupRef.value?.close()
|
||
|
emit('success')
|
||
|
}
|
||
|
|
||
|
//打开弹窗
|
||
|
const open = (type = 'add') => {
|
||
|
mode.value = type
|
||
|
popupRef.value?.open()
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
// 关闭回调
|
||
|
const handleClose = () => {
|
||
|
emit('close')
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
defineExpose({
|
||
|
open,
|
||
|
setFormData,
|
||
|
getDetail
|
||
|
})
|
||
|
</script>
|