<template>
|
<div class="system-add-user-container">
|
<el-dialog :title="title" v-model="isShowDialog" width="50%">
|
<el-form :model="form" size="default" ref="formRef" :rules="rules" label-width="120px">
|
<el-row :gutter="20">
|
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="生产工艺" prop="craftId">
|
<el-select v-model="form.craftId" filterable placeholder="请选择生产工艺" clearable style="width: 100%">
|
<el-option v-for="(item,index) in craftList" :key="index" :label="item.craftName" :value="item.uuid"/>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="年份" prop="theYear">
|
<el-date-picker
|
v-model="form.theYear"
|
type="year"
|
style="width: 100%"
|
value-format="YYYY"
|
/>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="一月产能" prop="janCapacity">
|
<el-input v-model.number.trim="form.janCapacity" placeholder="一月产能" type="number"/>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="二月产能" prop="febCapacity">
|
<el-input v-model.number.trim="form.febCapacity" placeholder="二月产能" type="number"/>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="三月产能" prop="marCapacity">
|
<el-input v-model.number.trim="form.marCapacity" placeholder="三月产能" type="number"/>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="四月产能" prop="aprCapacity">
|
<el-input v-model.number.trim="form.aprCapacity" placeholder="四月产能" type="number"/>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="五月产能" prop="mayCapacity">
|
<el-input v-model.number.trim="form.mayCapacity" placeholder="五月产能" type="number"/>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="六月产能" prop="juneCapacity">
|
<el-input v-model.number.trim="form.juneCapacity" placeholder="六月产能" type="number"/>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="七月产能" prop="julyCapacity">
|
<el-input v-model.number.trim="form.julyCapacity" placeholder="七月产能" type="number"/>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="八月产能" prop="augCapacity">
|
<el-input v-model.number.trim="form.augCapacity" placeholder="八月产能" type="number"/>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="九月产能" prop="sepCapacity">
|
<el-input v-model.number.trim="form.sepCapacity" placeholder="九月产能" type="number"/>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="十月产能" prop="octCapacity">
|
<el-input v-model.number.trim="form.octCapacity" placeholder="十月产能" type="number"/>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="十一月产能" prop="noveCapacity">
|
<el-input v-model.number.trim="form.noveCapacity" placeholder="十一月产能" type="number"/>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="mb20">
|
<el-form-item label="十二月产能" prop="decCapacity">
|
<el-input v-model.number.trim="form.decCapacity" placeholder="十二月产能" type="number"/>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20" v-if="title == '新增上报'? false : true">
|
<el-form-item label="删除状态" prop="deleted">
|
<el-radio-group v-model="form.deleted">
|
<el-radio :label="0">未删除</el-radio>
|
<el-radio :label="1">已删除</el-radio>
|
</el-radio-group>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<template #footer>
|
<span class="dialog-footer">
|
<el-button @click="isShowDialog = !isShowDialog" size="default">取 消</el-button>
|
<el-button type="primary" v-throttle @click="onSubmit" size="default">确 定</el-button>
|
</span>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script lang="ts">
|
import { reactive, toRefs, onMounted, defineComponent, ref } from 'vue';
|
import {ElMessageBox, ElMessage, FormRules, FormInstance} from 'element-plus';
|
import axios from "axios";
|
import {contractorApi} from "/@/api/dataUpload/contractorManage";
|
import Cookies from "js-cookie";
|
import {judgeReportApi} from "/@/api/dataUpload/saftyBaseInfo/judgeReport";
|
|
// 定义接口来定义对象的类型
|
interface DataState {
|
title: string
|
isShowDialog: boolean
|
form: {
|
uuid: string
|
craftId: string
|
theYear: string
|
janCapacity: number | null
|
febCapacity: number | null
|
marCapacity: number | null
|
aprCapacity: number | null
|
mayCapacity: number | null
|
juneCapacity: number | null
|
julyCapacity: number | null
|
augCapacity: number | null
|
sepCapacity: number | null
|
octCapacity: number | null
|
noveCapacity: number | null
|
decCapacity: number | null
|
deleted: number | null
|
}
|
rules:{}
|
craftList: []
|
}
|
|
export default defineComponent({
|
name: 'reportDialog',
|
props: [],
|
setup(props, context) {
|
const formRef = ref()
|
const addFormRef = ref()
|
const state = reactive<DataState>({
|
title: '',
|
isShowDialog: false,
|
form: {
|
uuid: '',
|
craftId: '',
|
theYear: '',
|
janCapacity: null,
|
febCapacity: null,
|
marCapacity: null,
|
aprCapacity: null,
|
mayCapacity: null,
|
juneCapacity: null,
|
julyCapacity: null,
|
augCapacity: null,
|
sepCapacity: null,
|
octCapacity: null,
|
noveCapacity: null,
|
decCapacity: null,
|
deleted: 0
|
},
|
rules:{
|
craftId: [{ required: true, message: '请选择生产工艺', trigger: 'blur' }],
|
theYear: [{ required: true, message: '请输入所属年份', trigger: 'blur' }]
|
},
|
craftList: []
|
})
|
|
// 页面加载时
|
onMounted(() => {
|
|
})
|
// 打开弹窗
|
const open = (type: string, data: object, list: []) => {
|
state.isShowDialog = true
|
state.craftList = list
|
if (type === 'add') {
|
state.title = '新增上报';
|
state.form = {
|
uuid: '',
|
craftId: '',
|
theYear: '',
|
janCapacity: null,
|
febCapacity: null,
|
marCapacity: null,
|
aprCapacity: null,
|
mayCapacity: null,
|
juneCapacity: null,
|
julyCapacity: null,
|
augCapacity: null,
|
sepCapacity: null,
|
octCapacity: null,
|
noveCapacity: null,
|
decCapacity: null,
|
deleted: 0
|
}
|
}else{
|
state.title = '重新上报';
|
Object.keys(state.form).forEach(key => {
|
if (Object.prototype.hasOwnProperty.call(data,key)) {
|
state.form[key] = JSON.parse(JSON.stringify(data))[key];
|
}
|
})
|
state.form.theYear = state.form.theYear.toString()
|
state.form.deleted = 0
|
}
|
}
|
|
// 新增修改
|
const onSubmit = async () => {
|
formRef.value.validate(async (valid:Boolean) => {
|
if(valid){
|
const res = await judgeReportApi().addCapacity([state.form])
|
if(res.data.code == 200){
|
ElMessage({
|
type:'success',
|
message:'数据上报成功'
|
})
|
state.isShowDialog = false
|
}else{
|
ElMessage({
|
type:'warning',
|
message:res.data.msg
|
})
|
}
|
context.emit('refresh');
|
}else{
|
ElMessage({
|
type:'warning',
|
message:'请完善基本信息'
|
})
|
}
|
})
|
}
|
|
|
return {
|
formRef,
|
addFormRef,
|
open,
|
onSubmit,
|
...toRefs(state)
|
};
|
}
|
});
|
</script>
|