138 lines
3.9 KiB
Vue
138 lines
3.9 KiB
Vue
|
|
NEW_FILE_CODE
|
||
|
|
<template>
|
||
|
|
<el-dialog
|
||
|
|
:title="!dataForm.id ? '新建' : '编辑'"
|
||
|
|
:visible.sync="dialogVisible"
|
||
|
|
width="600px"
|
||
|
|
:close-on-click-modal="false"
|
||
|
|
@close="handleClose"
|
||
|
|
>
|
||
|
|
<el-form ref="formRef" :model="dataForm" :rules="dataRule" size="small" label-width="100px" label-position="right">
|
||
|
|
<template v-if="!loading">
|
||
|
|
<el-form-item label="工艺流程" prop="techProc">
|
||
|
|
<JnpfInput v-model="dataForm.techProc" placeholder="请输入工艺流程" clearable :style="{ width: '100%' }">
|
||
|
|
</JnpfInput>
|
||
|
|
</el-form-item>
|
||
|
|
<el-form-item label="状态" prop="enabledStatus">
|
||
|
|
<JnpfSelect v-model="dataForm.enabledStatus" placeholder="请选择状态" :options="enabledStatusOptions" :props="enabledStatusProps" clearable :style="{ width: '100%' }">
|
||
|
|
</JnpfSelect>
|
||
|
|
</el-form-item>
|
||
|
|
<el-form-item label="备注" prop="remark">
|
||
|
|
<JnpfTextarea v-model="dataForm.remark" placeholder="请输入备注" :style="{ width: '100%' }" :autoSize="{ minRows: 4, maxRows: 4 }" type="textarea">
|
||
|
|
</JnpfTextarea>
|
||
|
|
</el-form-item>
|
||
|
|
</template>
|
||
|
|
</el-form>
|
||
|
|
<div slot="footer" class="dialog-footer">
|
||
|
|
<el-button type="primary" @click="dataFormSubmit()" :loading="btnLoading">保 存</el-button>
|
||
|
|
<el-button @click="handleClose">取 消</el-button>
|
||
|
|
</div>
|
||
|
|
</el-dialog>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
import request from '@/utils/request'
|
||
|
|
import { mapGetters } from 'vuex'
|
||
|
|
|
||
|
|
export default {
|
||
|
|
components: {},
|
||
|
|
props: [],
|
||
|
|
data() {
|
||
|
|
return {
|
||
|
|
dialogVisible: false,
|
||
|
|
loading: false,
|
||
|
|
btnLoading: false,
|
||
|
|
formRef: 'formRef',
|
||
|
|
eventType: '',
|
||
|
|
dataForm: {
|
||
|
|
id: '',
|
||
|
|
techProc: undefined,
|
||
|
|
enabledStatus: 1,
|
||
|
|
remark: undefined,
|
||
|
|
},
|
||
|
|
dataRule: {
|
||
|
|
techProc: [
|
||
|
|
{
|
||
|
|
required: true,
|
||
|
|
message: '请输入工艺流程',
|
||
|
|
trigger: 'blur',
|
||
|
|
},
|
||
|
|
],
|
||
|
|
enabledStatus: [
|
||
|
|
{
|
||
|
|
required: true,
|
||
|
|
message: '请选择状态',
|
||
|
|
trigger: 'change',
|
||
|
|
},
|
||
|
|
],
|
||
|
|
},
|
||
|
|
enabledStatusOptions: [
|
||
|
|
{ fullName: "启用", id: 1 },
|
||
|
|
{ fullName: "未启用", id: 2 },
|
||
|
|
],
|
||
|
|
enabledStatusProps: { label: "fullName", value: "id" },
|
||
|
|
}
|
||
|
|
},
|
||
|
|
computed: {
|
||
|
|
...mapGetters(['userInfo']),
|
||
|
|
},
|
||
|
|
methods: {
|
||
|
|
init(id) {
|
||
|
|
this.dataForm.id = id || '';
|
||
|
|
this.dialogVisible = true;
|
||
|
|
this.loading = true;
|
||
|
|
this.$nextTick(() => {
|
||
|
|
this.$refs.formRef.resetFields();
|
||
|
|
if (this.dataForm.id) {
|
||
|
|
request({
|
||
|
|
url: `/api/example/techproc/${this.dataForm.id}`,
|
||
|
|
method: 'get'
|
||
|
|
}).then(res => {
|
||
|
|
this.dataForm = res.data
|
||
|
|
this.loading = false
|
||
|
|
})
|
||
|
|
} else {
|
||
|
|
this.loading = false
|
||
|
|
}
|
||
|
|
});
|
||
|
|
},
|
||
|
|
dataFormSubmit() {
|
||
|
|
this.$refs.formRef.validate((valid) => {
|
||
|
|
if (valid) {
|
||
|
|
this.btnLoading = true;
|
||
|
|
const isEdit = !!this.dataForm.id;
|
||
|
|
const url = isEdit ? `/api/example/techproc/${this.dataForm.id}` : '/api/example/techproc';
|
||
|
|
const method = isEdit ? 'put' : 'post';
|
||
|
|
|
||
|
|
request({
|
||
|
|
url: url,
|
||
|
|
method: method,
|
||
|
|
data: this.dataForm
|
||
|
|
}).then(res => {
|
||
|
|
this.$message({
|
||
|
|
message: res.msg,
|
||
|
|
type: 'success',
|
||
|
|
duration: 1500,
|
||
|
|
onClose: () => {
|
||
|
|
this.btnLoading = false;
|
||
|
|
this.dialogVisible = false;
|
||
|
|
this.$emit('refresh', true)
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}).catch(() => {
|
||
|
|
this.btnLoading = false
|
||
|
|
})
|
||
|
|
}
|
||
|
|
})
|
||
|
|
},
|
||
|
|
handleClose() {
|
||
|
|
this.dialogVisible = false;
|
||
|
|
this.$emit('refresh',true)
|
||
|
|
},
|
||
|
|
changeData(model, index) {
|
||
|
|
this.isEdit = true
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</script>
|