133 lines
3.6 KiB
Plaintext
133 lines
3.6 KiB
Plaintext
<template>
|
|
<div style="text-align: center" :v-loading="divLoading">
|
|
<fm-generate-form v-if="isShow" :data="jsonData" ref="generateForm"> </fm-generate-form>
|
|
|
|
<el-row v-if="isOperate">
|
|
<el-button type="primary" @click="handleSubmit">提交数据</el-button>
|
|
<el-button type="primary" @click="handleReset">返回</el-button>
|
|
</el-row>
|
|
</div>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
import axios from '@/api/mes/http'
|
|
export default {
|
|
name: "generateForm",
|
|
props: {
|
|
layerid: {
|
|
type: String,
|
|
default: "",
|
|
},
|
|
lydata: {
|
|
type: Object,
|
|
default: () => {
|
|
return {};
|
|
},
|
|
},
|
|
},
|
|
data() {
|
|
return {
|
|
divLoading: false,
|
|
isOperate: true, //是否是操作进入模板
|
|
jsonData: {},
|
|
editData: {},
|
|
isShow:false,
|
|
};
|
|
},
|
|
mounted() {
|
|
console.log('11111',this.lydata)
|
|
|
|
|
|
this.$nextTick(() => {
|
|
this.getTemplateJson();
|
|
});
|
|
|
|
//表单加载完后才能赋值
|
|
// this.divLoading = true;
|
|
// this.g_method.sidebarReduce();
|
|
// setTimeout(() => {
|
|
// let dataJson = this.dealEditData(JSON.parse(this.editData))
|
|
// console.log(dataJson, "1047");
|
|
// this.$refs.generateForm.setData(JSON.parse(this.editData));
|
|
// this.divLoading = false;
|
|
// }, 1000);
|
|
},
|
|
methods: {
|
|
getTemplateJson() {
|
|
let obj= {id:this.lydata.templateId}
|
|
|
|
//{id:449}
|
|
|
|
axios.get('/basic/template/getTemplateJson',{params:obj}).then(data=>{
|
|
console.log('11111111',data)
|
|
this.jsonData=JSON.parse(data.data.data)
|
|
this.isShow=true
|
|
})
|
|
|
|
},
|
|
dealEditData(editData) {
|
|
if (editData.use_count === null || editData.use_count === undefined )
|
|
editData.use_count = 0
|
|
if (editData.usedTotal === 'null')
|
|
editData.usedTotal = 0
|
|
return editData
|
|
},
|
|
async moveCurrentToLast() {
|
|
const submitData = await this.$refs.generateForm.getData()
|
|
// console.log(submitData, '模板数据')
|
|
if (submitData.current_value1 || submitData.current_value2
|
|
|| submitData.current_value3 || submitData.current_value4 || submitData.current_value5) {
|
|
submitData.lastuse_value1 = submitData.current_value1
|
|
submitData.lastuse_value2 = submitData.current_value2
|
|
submitData.lastuse_value3 = submitData.current_value3
|
|
submitData.lastuse_value4 = submitData.current_value4
|
|
submitData.lastuse_value5 = submitData.current_value5
|
|
submitData.current_value1 = ''
|
|
submitData.current_value2 = ''
|
|
submitData.current_value3 = ''
|
|
submitData.current_value4 = ''
|
|
submitData.current_value5 = ''
|
|
}
|
|
this.$refs.generateForm.setData(submitData)
|
|
},
|
|
handleSubmit() {
|
|
this.$refs.generateForm
|
|
.getData()
|
|
.then((data) => {
|
|
console.log(JSON.stringify(data));
|
|
let param = {
|
|
id: this.lydata.templateId,
|
|
dataJson: JSON.stringify(data),
|
|
// templateId: this.lydata.templateId,
|
|
};
|
|
|
|
this.$templateData.updateData(param).then((res) => {
|
|
if (res.status == 200) {
|
|
this.$message.success("提交成功");
|
|
}
|
|
|
|
this.$layer.close(this.layerid);
|
|
});
|
|
})
|
|
.catch((e) => {});
|
|
},
|
|
handleReset() {
|
|
this.$layer.close(this.layerid);
|
|
},
|
|
|
|
resetHight() {
|
|
//修改弹出层 表单的高度
|
|
let content = document.getElementsByClassName("vl-notify-content");
|
|
console.log(content);
|
|
content[0].style.height = "100%";
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
<style scoped>
|
|
.vl-notify-content {
|
|
height: 100%;
|
|
}
|
|
</style>
|