Commit ef1e6c31 by 潘际乾

pty静态交易完善

parent 886cdcf7
...@@ -152,6 +152,12 @@ export default class Utils { ...@@ -152,6 +152,12 @@ export default class Utils {
return output.join(''); return output.join('');
} }
/**
* 执行checkAll之后根据返回的错误信息定位
* @param {Object} fieldErrors 错误信息
* @param {Array} formFields 表单字段
* @returns El-Tab实例
*/
static positioningErrorMsg(fieldErrors, formFields) { static positioningErrorMsg(fieldErrors, formFields) {
if (Object.keys(fieldErrors).length === 0) { if (Object.keys(fieldErrors).length === 0) {
return null; return null;
...@@ -189,7 +195,60 @@ export default class Utils { ...@@ -189,7 +195,60 @@ export default class Utils {
} }
if (firstErrorTab) { if (firstErrorTab) {
const tabs = firstErrorTab.$parent const tabs = firstErrorTab.$parent
tabs.value = firstErrorTab.name tabs.currentName = firstErrorTab.name
}
if (collapsePanel && collapsePanel.collapse.activeNames.indexOf(collapsePanel.name) < 0) {
collapsePanel.collapse.activeNames.push(collapsePanel.name)
}
setTimeout(() => {
// 滚动到指定节点
firstErrorItem.$el.scrollIntoView({
// 值有start,center,end,nearest,当前显示在视图区域中间
block: 'center',
// 值有auto、instant,smooth,缓动动画(当前是慢速的)
behavior: 'smooth'
})
}, 0)
}
return firstErrorTab;
}
/**
* 表单自身的validate方法执行后,错误提示定位
* @param {Array} formFields 表单字段
* @returns El-Tab实例
*/
static formValidateTips(formFields) {
let firstErrorItem = null
// 顺序
for (let i = 0; i < formFields.length; i++) {
const field = formFields[i];
if (field.validateState === 'error') {
firstErrorItem = field
break;
}
}
let firstErrorTab = null, collapsePanel = null
if (firstErrorItem) {
let parentVC = firstErrorItem
while(!firstErrorTab) {
const vcName = parentVC.$options.componentName
// 没有Tabs的表单
if (vcName === "ElForm") {
break;
}
if (vcName === "ElTabPane") {
firstErrorTab = parentVC
break;
}
if (vcName === "ElCollapseItem") {
collapsePanel = parentVC;
}
parentVC = parentVC.$parent;
}
if (firstErrorTab) {
const tabs = firstErrorTab.$parent
tabs.currentName = firstErrorTab.name
} }
if (collapsePanel && collapsePanel.collapse.activeNames.indexOf(collapsePanel.name) < 0) { if (collapsePanel && collapsePanel.collapse.activeNames.indexOf(collapsePanel.name) < 0) {
collapsePanel.collapse.activeNames.push(collapsePanel.name) collapsePanel.collapse.activeNames.push(collapsePanel.name)
......
<template> <template>
<m-pty title="dbapty" type="add"></m-pty> <m-pty ref="pty" title="dbapty" type="add"></m-pty>
</template> </template>
<script> <script>
...@@ -13,6 +13,11 @@ export default { ...@@ -13,6 +13,11 @@ export default {
data() { data() {
return {}; return {};
}, },
mounted() {
this.$refs.pty.rules['ptaList'] = [
{ type: 'array', required: true, min: 1, message: '地址信息栏不能为空' }
]
}
}; };
</script> </script>
......
...@@ -47,6 +47,9 @@ export default class Pty { ...@@ -47,6 +47,9 @@ export default class Pty {
namelc: "", namelc: "",
adrelc: "", adrelc: "",
dtgcid: "", dtgcid: "",
// pat
usgpat: '',
adrstapat: ''
} }
} }
} }
......
...@@ -3,37 +3,39 @@ ...@@ -3,37 +3,39 @@
<div style="text-align: right"> <div style="text-align: right">
<c-button size="small" type="primary" @click="adrAdd()"> 新增 </c-button> <c-button size="small" type="primary" @click="adrAdd()"> 新增 </c-button>
</div> </div>
<c-table :columnsConfig="columns" :list="model.ptaList"> <el-form-item label="" label-width="0" prop="ptaList">
<c-table-column fixed="right" prop="op" label="操作" width="200px"> <c-table :columnsConfig="columns" :list="model.ptaList">
<template slot-scope="{ scope }"> <c-table-column fixed="right" prop="op" label="操作" width="200px">
<button <template slot-scope="{ scope }">
class="el-button el-button--default el-button--small" <button
style="margin-left: 0" class="el-button el-button--default el-button--small"
size="small" style="margin-left: 0"
:disabled="false" size="small"
@click.prevent="adrInfo(scope.$index, scope.row)" :disabled="false"
> @click.prevent="adrInfo(scope.$index, scope.row)"
<span>详情</span> >
</button> <span>详情</span>
<c-button </button>
style="margin-left: 5px" <c-button
size="small" style="margin-left: 5px"
type="primary" size="small"
@click="adrEdit(scope.$index, scope.row)" type="primary"
> @click="adrEdit(scope.$index, scope.row)"
修改 >
</c-button> 修改
<c-button </c-button>
style="margin-left: 5px" <c-button
size="small" style="margin-left: 5px"
type="primary" size="small"
@click="adrDelete(scope.$index, scope.row)" type="primary"
> @click="adrDelete(scope.$index, scope.row)"
删除 >
</c-button> 删除
</template> </c-button>
</c-table-column> </template>
</c-table> </c-table-column>
</c-table>
</el-form-item>
<el-dialog <el-dialog
:title=" :title="
...@@ -86,6 +88,7 @@ export default { ...@@ -86,6 +88,7 @@ export default {
components: { components: {
"m-adr-info": AdrInfo, "m-adr-info": AdrInfo,
}, },
inject: ["root"],
props: ["model"], props: ["model"],
data() { data() {
return { return {
...@@ -110,23 +113,35 @@ export default { ...@@ -110,23 +113,35 @@ export default {
}; };
}, },
methods: { methods: {
/**
* 详情
*/
adrInfo(index, row) { adrInfo(index, row) {
this.adr = { ...row }; this.adr = { ...row };
this.operate = "details"; this.operate = "details";
this.operateIdx = index; this.operateIdx = index;
this.adrDialog = true; this.adrDialog = true;
}, },
/**
* 新增
*/
adrAdd() { adrAdd() {
this.adr = new Adr().data; this.adr = new Adr().data;
this.operate = "add"; this.operate = "add";
this.adrDialog = true; this.adrDialog = true;
}, },
/**
* 修改
*/
adrEdit(index, row) { adrEdit(index, row) {
this.adr = { ...row }; this.adr = { ...row };
this.operate = "edit"; this.operate = "edit";
this.operateIdx = index; this.operateIdx = index;
this.adrDialog = true; this.adrDialog = true;
}, },
/**
* 删除
*/
adrDelete(index, row) { adrDelete(index, row) {
this.$confirm("是否真的删除?", "提示", { this.$confirm("是否真的删除?", "提示", {
confirmButtonText: "确认", confirmButtonText: "确认",
...@@ -164,23 +179,33 @@ export default { ...@@ -164,23 +179,33 @@ export default {
} }
}); });
}, },
/**
* Adr新增有2种情况
* 1. pty的新增界面下,此时pty的inr为空,adr需要在pty插入之后,才能执行新增,
* 所以我们在这里不能直接调用新增接口,将adr添加到ptaList中,随着这个pty一起传入接口。
* 2. pty的修改界面下,可直接新增 ;
*/
saveAdr() { saveAdr() {
this.$refs.adr.$refs.modelForm.validate((validated) => { if (this.root.type === "add") {
if (validated) { this.model.ptaList.push(this.adr);
addAdrData(this.model.inr, this.adr) this.handleClose();
.then((res) => { } else {
if (res) { this.$refs.adr.$refs.modelForm.validate((validated) => {
this.$message.success("保存地址信息成功!"); if (validated) {
// this.model.ptaList.push(res); addAdrData(this.model.inr, this.adr)
this.model.ptaList = res.ptaList; .then((res) => {
this.handleClose(); if (res && res.inr) {
} this.$message.success("保存地址信息成功!");
}) this.model.ptaList = res.ptaList;
.catch((error) => { this.handleClose();
this.$message.error("保存地址信息失败!"); }
}); })
} .catch((error) => {
}); this.$message.error("保存地址信息失败!");
});
}
});
}
}, },
handleClose(done) { handleClose(done) {
this.adrDialog = false; this.adrDialog = false;
......
...@@ -68,6 +68,7 @@ ...@@ -68,6 +68,7 @@
</template> </template>
<script> <script>
import Utils from "~/utils";
import Pty, { Pattern } from "./Pty.js"; import Pty, { Pattern } from "./Pty.js";
import PtyInfo from "./PtyInfo.vue"; import PtyInfo from "./PtyInfo.vue";
...@@ -138,6 +139,8 @@ export default { ...@@ -138,6 +139,8 @@ export default {
.catch((err) => { .catch((err) => {
this.$message.error("保存失败!"); this.$message.error("保存失败!");
}); });
} else {
Utils.formValidateTips(this.$refs.modelForm.fields)
} }
}); });
}, },
...@@ -152,6 +155,8 @@ export default { ...@@ -152,6 +155,8 @@ export default {
.catch((err) => { .catch((err) => {
this.$message.error("保存失败!"); this.$message.error("保存失败!");
}); });
} else {
Utils.formValidateTips(this.$refs.modelForm.fields)
} }
}); });
}, },
...@@ -185,6 +190,7 @@ export default { ...@@ -185,6 +190,7 @@ export default {
this.$store.dispatch("TagsView/delView", this.$route); this.$store.dispatch("TagsView/delView", this.$route);
this.$router.push({ name: "StaticsInfpty", params: { update } }); this.$router.push({ name: "StaticsInfpty", params: { update } });
}, },
}, },
}; };
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment