|
|
<template> <el-dialog v-drag width="200px" :title="!dataForm.id ? buttons.add :buttons.edit" :close-on-click-modal="false" :visible.sync="visible">
<el-form label-position="top" ref="dataForm" label-width="80px"> <el-form-item :label="buttons.site || '工厂编号'" prop="baseData"> <el-input v-model="dataForm.baseData" style="width: 160px"></el-input> </el-form-item> <el-form-item :label="buttons.siteDesc || '工厂描述'" prop="baseDesc"> <el-input v-model="dataForm.baseDesc" style="width: 160px"></el-input> </el-form-item> <el-form-item :label="buttons.siteRemark || '工厂备注'" prop="remark"> <el-input v-model="dataForm.remark" style="width: 160px"></el-input> </el-form-item> </el-form>
<span slot="footer" class="dialog-footer"> <el-button type="primary" @click="dataFormSubmit()">{{buttons.submit ||'确定'}}</el-button> <el-button type="primary" @click="visible = false">{{ buttons.close|| '关闭' }}</el-button> </span> </el-dialog></template>
<script>import { searchSysLanguageParam, searchFunctionButtonList, saveButtonList,} from "@/api/sysLanguage.js"export default { data() { return { visible: false, dataForm: { id: 0, site: 'ALL', type: '', secondType: 'site_code', baseData: '', baseDesc: '', status: '1', sortNo: '', remark: '', }, buttons: { submit: '确定', add: '添加', edit: '添加', close: '关闭', site:'工厂编号', siteDesc:'工厂描述', siteRemark:'工厂备注', }, } }, methods: { init(id, baseColumns) { this.dataForm.id = id || 0 this.visible = true this.$nextTick(() => { this.$refs['dataForm'].resetFields() if (this.dataForm.id) { this.$http({ url: this.$http.adornUrl(`/factory/tblbasedata/info/` + this.dataForm.id), method: 'get', params: this.$http.adornParams() }).then(({data}) => { if (data && data.code === 0) { this.dataForm.site = data.data.site this.dataForm.type = data.data.type this.dataForm.secondType = data.data.secondType this.dataForm.baseData = data.data.baseData this.dataForm.baseDesc = data.data.baseDesc this.dataForm.status = data.data.status this.dataForm.sortNo = data.data.sortNo this.dataForm.remark = data.data.remark } }) } }) }, // 表单提交
dataFormSubmit() { if (!this.dataForm.baseData) this.$message.error('工厂编号不能为空'); return if (!this.dataForm.baseDesc) this.$message.error('工厂描述不能空'); return this.$http({ url: this.$http.adornUrl(`/factory/tblbasedata/${!this.dataForm.id ? 'save' : 'update'}`), method: 'post', data: this.$http.adornData({ 'id': this.dataForm.id || undefined, 'site': this.dataForm.site, 'type': this.dataForm.type, 'secondType': this.dataForm.secondType, 'baseData': this.dataForm.baseData, 'baseDesc': this.dataForm.baseDesc, 'status': this.dataForm.status, 'sortNo': this.dataForm.sortNo, 'remark': this.dataForm.remark }) }).then(({data}) => { if (data && data.code === 0) { this.$message.success( '操作成功') this.visible = false this.$emit('refreshDataList') } else { this.$message.error(data.msg) } }) }, getFunctionButtonList() { let queryButton = { functionId: '998001', tableId: '*', languageCode: this.$i18n.locale, objectType: 'button' } searchFunctionButtonList(queryButton).then(({data}) => { if (data.code == 0 && data.data) { this.buttons = data.data } }) }, }, created() { this.getFunctionButtonList() }}</script>
|