123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- <template>
- <!-- 列表选择弹窗 -->
- <f-dialog
- ref="dialog"
- title="基础库配置信息"
- :initData="handleInitData"
- :isDetermine="dialogType!=='detail'"
- :beforeClose="handleBeforeClose"
- width="1100px"
- >
- <template #contain>
- <f-form
- ref="ruleForm"
- :form="fromData"
- :disabled="dialogType==='detail'"
- :config="fromDataConfig"
- :rules="fromRules"
- label-position="left"
- :column="2"
- :key="fromKey"
- />
- </template>
- </f-dialog>
- </template>
- <script>
- import { addBaseApi } from '@/api/base/addBase'
- export default {
- name: "DetailDialog",
- props: {
- // 表单数据
- rowData:{
- type:Object,
- default:()=>{}
- },
- // 表单类型 add detail edit
- dialogType:{
- type:String,
- default:'add'
- }
- },
- data() {
- return {
- // 数据对象
- fromData:{
- },
- // 表单配置
- fromDataConfig:[
- {
- itemType: "input",
- prop: "name",
- label:'基础库名',
- attrs: {
- placeholder: "请输入基础库名"
- },
- },
- {
- itemType: "input",
- prop: "bandValue",
- label:'波段值',
- attrs: {
- inputType:'Number',
- placeholder: "请输入波段值,默认38000"
- },
- },
- {
- itemType: "input",
- prop: "repeatCode",
- label:'重复码',
- attrs: {
- placeholder: "请输入重复码"
- },
- },
- {
- itemType: "input",
- prop: "bootCode",
- label:'引导码',
- attrs: {
- placeholder: "请输入引导码"
- },
- },
- {
- itemType: "input",
- prop: "bootCodeSend",
- label:'引导码发送次数',
- attrs: {
- inputType:'Number',
- placeholder: "请输入引导码发送次数"
- },
- },
- {
- itemType: "input",
- prop: "synchronizeCode",
- label:'同步码',
- attrs: {
- placeholder: "请输入同步码"
- },
- },
- {
- itemType: "input",
- prop: "synchronizeCodeSend",
- label:'同步码发送次数',
- attrs: {
- inputType:'Number',
- placeholder: "请输入同步码发送次数"
- },
- },
- {
- itemType: "input",
- prop: "dateCode",
- label:'数据',
- attrs: {
- placeholder: "请输入数据",
- span:2,
- type:'textarea'
- },
- },
- {
- itemType: "input",
- prop: "overCode",
- label:'结束码',
- attrs: {
- placeholder: "请输入结束码"
- },
- },
- {
- itemType: "input",
- prop: "dateBinary0",
- label:'数据二进制0',
- attrs: {
- placeholder: "请输入数据二进制0"
- },
- },
- {
- itemType: "input",
- prop: "dateBinary1",
- label:'数据二进制1',
- attrs: {
- placeholder: "请输入数据二进制1"
- },
- }
- ],
- // 表单验证
- fromRules:{
- name:[{required: true, message: '请输入基础库名'}],
- bootCode:[{required: true, message: '请输入引导码'}],
- bootCodeSend:[{required: true, message: '请输入引导码发送次数'}],
- dateCode:[{required: true, message: '请输入数据'}],
- overCode:[{required: true, message: '请输入结束码'}],
- dateBinary0:[{required: true, message: '请输入数据二进制0'}],
- dateBinary1:[{required: true, message: '请输入数据二进制1'}]
- },
- // 表单key
- fromKey:0
- };
- },
- methods: {
- // 显示弹窗
- show(){
- this.$refs.dialog.show();
- },
- // 初始化表单数据
- initFormData(fromData){
- this.fromData = {
- content:'',
- ...fromData
- }
- this.fromKey++;
- },
- // 详情
- async handleInitData(){
- const {dialogType,rowData} = this;
- if(dialogType === 'add') return this.initFormData({})
- // 调接口获取详情
- const res = await addBaseApi.configDetail({ id: rowData.id });
- if(res.code != 200) return this.initFormData({})
- const from = { ...res.data }
- this.initFormData(from);
- },
- // 关闭之前回调.
- async handleBeforeClose(type){
- if(type !='ok') return true;
- const validate = await this.$refs.ruleForm.validate();
- if(!validate) return false;
- const params = {
- ...this.fromData,
- // bandValue: Number(this.fromData.bandValue),
- // bootCodeSend: Number(this.fromData.bootCodeSend)
- }
- // 调接口更新数据
- const res = await addBaseApi.configAddOrEdit(params);
- if(res.code !=200){
- this.$modal.msgError(res.msg);
- return false;
- }
- this.$emit('updateList')
- this.initFormData({})
- return true;
- }
- }
- }
- </script>
- <style scoped lang="scss"></style>
|